htaccess caching code – Speed Boost Cache Code

Home Forums BulletProof Security Pro htaccess caching code – Speed Boost Cache Code

Viewing 15 posts - 1 through 15 (of 35 total)
  • Author
    Posts
  • #8652
    AITpro Admin
    Keymaster

    The Speed Boost Cache code is htaccess Browser caching code. You may see significant website load speed performance or you may only see minor website load speed improvement, but you should see some website performance improvement. You can do benchmark/website load speed/performance testing/checking with Firefox, Firebug, Firephp and Yslow or you can use one of the online website speed testing sites such as Google PageSpeed Insights, Pingdom or GTmetrix.

    Internet Speed Testing site: InternetAdvisor

    Important Note: If you are already have a caching plugin installed (WPSC, W3TC, WPFC, Comet Cache, WP Rocket, etc) and have already added your caching plugin’s Browser caching code in BPS Custom Code then do not also add the BPS Speed Boost Browser caching code. Adding duplicate or redundant Browser caching code will not improve website performance and may actually cause your website to perform/load slower.  See this forum topic for additional detailed help information: https://forum.ait-pro.com/forums/topic/bps-speed-boost-cache-custom-code-notice/

    1. Copy the Speed Boost .htaccess code below into this BPS Root Custom Code text box: CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE
    2. Click the Save Root Custom Code button.
    3. BPS Pro 11.9+ & BPS .53.8+: Go to the BPS Security Modes page and click the Root Folder BulletProof Mode Activate button.
    3. Older BPS versions: Go to the BPS Security Modes page, click the Create secure.htaccess File AutoMagic button, select the Activate Root Folder BulletProof Mode Radio button and click the Activate|Deactivate button.

    Notes: If you are using php/php.ini handler htaccess code (or add php/php.ini handler htaccess code to BPS Custom Code at a later time) then the correct order of htaccess code in the CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE text box is:  php/php.ini handler htaccess code first and then Speed Boost .htaccess code goes after/below your php/php.ini handler htaccess code in the CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE text box.

    # BEGIN WEBSITE SPEED BOOST
    # Time cheat sheet in seconds
    # A86400 = 1 day
    # A172800 = 2 days
    # A2419200 = 1 month
    # A4838400 = 2 months
    # A29030400 = 1 year
    
    # Test which ETag setting works best on your Host/Server/Website
    # with Firefox Firebug, Firephp and Yslow benchmark tests.
    
    # Create the ETag (entity tag) response header field
    # This is probably not the optimum choice to use.
    #FileETag MTime Size
    
    # Remove the ETag (entity tag) response header field
    # This is most likely the optimum choice to use.
    Header unset ETag
    FileETag none
    
    <IfModule mod_expires.c>
    ExpiresActive on
    # ExpiresByType overrides the ExpiresDefault...
    # cache expiration time of 2 days|A172800.
    ExpiresDefault A172800
    ExpiresByType image/jpg A4838400
    ExpiresByType image/jpeg A4838400
    ExpiresByType image/gif A4838400
    ExpiresByType image/png A4838400
    ExpiresByType image/bmp A4838400
    ExpiresByType image/x-icon A4838400
    ExpiresByType image/svg+xml A4838400
    ExpiresByType text/javascript A4838400
    ExpiresByType text/x-javascript A4838400 
    ExpiresByType text/css A4838400
    ExpiresByType text/html A4838400
    ExpiresByType application/x-font-ttf A4838400
    ExpiresByType application/x-font-woff A4838400
    ExpiresByType font/opentype A4838400
    ExpiresByType application/x-shockwave-flash A4838400
    ExpiresByType application/x-javascript A4838400
    ExpiresByType application/javascript A4838400
    ExpiresByType video/mp4 A4838400
    ExpiresByType video/ogg A4838400
    ExpiresByType video/webm A4838400
    </IfModule>
    
    <IfModule mod_headers.c>
    <FilesMatch "\.(js|css|flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|gif|jpg|jpeg|png|swf|webm)$">
    Header append Cache-Control "public"
    </FilesMatch>
    <FilesMatch "\.(txt|html)$">
    Header append Cache-Control "proxy-revalidate"
    </FilesMatch>
    <FilesMatch "\.(php|cgi|pl|htm|xml)$">
    Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
    Header set Pragma "no-cache"
    </FilesMatch>
    </IfModule>
    
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript
    AddOutputFilterByType DEFLATE application/javascript application/x-javascript
    AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp
    AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/xml-dtd
    AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf
    AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf
    AddOutputFilterByType DEFLATE image/svg+xml
    
    # Drop problematic browsers
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
    </IfModule>
    # END WEBSITE SPEED BOOST

    Extra General Info:
    You can use the code exactly as is or if you want to see if you can get a couple more milliseconds of speed:
    Test using no ETags by commenting out (adding a pound sign #) all the ETag lines of .htaccess code below (#FileETag MTime Size, #Header unset ETag, #FileETag none) and benchmark test website performance, then benchmark test using Header unset and FileETag none (this is currently the default code shown below) and then benchmark test using FileETag MTime Size (uncomment FileETag MTime Size and comment out #Header unset ETag, #FileETag none).  Whichever ETag combination/choice makes your website perform the fastest is the one you want to use/keep.  On Go Daddy it seems that using Header unset ETag and FileETag none is slightly faster in milliseconds (as shown below).

    Testing examples explained above are here:  http://forum.ait-pro.com/forums/topic/htaccess-caching-code-speed-boost-cache-code/#post-9707

    #9547
    AITpro Admin
    Keymaster

    Question copied from another topic to this relevant topic:

    Whichever ETag combination/choice makes your website perform the fastest. On Go Daddy it seems… Do you have practical knowledge what’s best on 1and1 managed servers?
    Nane

    #9550
    AITpro Admin
    Keymaster

    Nope, each person will have to test whichever works best for their Host and if you want to post back here that would be great to help other folks out.

    #9593
    Juan Pablo
    Participant

    Hi, i don’t understand what i must do it. Can you clarify, what i must do?.
    Thanks in advance.

    #9594
    AITpro Admin
    Keymaster

    Watch this Custom Code Video Tutorial.  If you still have any questions after watching the video tutorial then post those questions.
    http://forum.ait-pro.com/video-tutorials/#custom-code

    #9705
    Blair Wolf
    Participant

    I have been dicking with this for half a day trying to figure out what I’m supposed to comment out/in. I don’t get it and the video was no real help. Remember, most of us are not engineers or have degrees in computer science. What is “Header unset” and “FileETag MTime Size” and what does it look like in that list of code or in short WTF am I doing.

    Just goes to show you if you don’t put it layman terms, so everyone can understand it, you get a lot of stupid questions.

    #9707
    AITpro Admin
    Keymaster

    Ok let me try and make this a no-brainer.

    The first test should be done with all of these things below commented out with pound signs #

    # Test which ETag setting works best on your Host/Server/Website
    # with Firefox Firebug, Firephp and Yslow benchmark tests.
    
    # Create the ETag (entity tag) response header field
    #FileETag MTime Size
    
    # Remove the ETag (entity tag) response header field
    #Header unset ETag
    #FileETag none

    The next test should be done with these things commented out

    # Test which ETag setting works best on your Host/Server/Website
    # with Firefox Firebug, Firephp and Yslow benchmark tests.
    
    # Create the ETag (entity tag) response header field
    FileETag MTime Size
    
    # Remove the ETag (entity tag) response header field
    #Header unset ETag
    #FileETag none

    The final test should be done with these things uncommented/commented out because most likely this is going to be the optimum choice.

    # Test which ETag setting works best on your Host/Server/Website
    # with Firefox Firebug, Firephp and Yslow benchmark tests.
    
    # Create the ETag (entity tag) response header field
    #FileETag MTime Size
    
    # Remove the ETag (entity tag) response header field
    Header unset ETag
    FileETag none
    #10084
    Zac
    Participant

    So the first step is to test the code.. having all the *test instructions disabled with the pound symbol “comment out”. And what are we to observe after this step?
    Step 2, same thing only this is enabled (FileETag MTime Size) by the removal of # comment tag. And again, why are we doing this or what am I to observe from this test?
    Step 3: Is even more confusing, we are suppose to enable or disable what? You have only requested that we enable the one line of code in step 2, and somehow we should know what to disable or enable. How does step one, (no changes) and step 2 lead to step 3’s list of optimal settings?

    #10105
    AITpro Admin
    Keymaster

    @ Zac – Ok how about this for simple:  Use the code exactly as it is and it will work fine.  Benchmarking speed testing would be done using Firefox and these Firefox add-ons:  Firebug, Firephp and YSlow.  This is actually not really necessary because the difference in speed is going to be only a couple of milliseconds difference max, so therefore it is not really necessary to benchmark test for a speed differences since a couple of milliseconds is going to be completely insignificant for most folks.  Some folks care about a couple of milliseconds, but most do not.  😉

    #10506
    Tim McGuinness
    Participant

    AIT,

    Look you guys are brilliant.  You have kept my sites hack free for 2 years and counting now! [knock on wood], but you are not the most user friendly designers.  You basic security plugin is a nightmare for novices.  Think ONE CLICK.  This is a perfect example.  I gave up on your speed fix, after having broken a couple of sites.  The restore wasn’t a problem, but it points out that you need this in a plugin with a single click interface.  I won’t mind paying for it – but keep life simple for those of us that have to maintain our sites.

    #10524
    AITpro Admin
    Keymaster

    @ Tim McGuinness – we have taken your thoughts into consideration.  Thank you.

    #12424
    Akhil K A
    Participant

    WOW.. I got speed boost.. 7sec to 4sec. Thanks, and I support Tim McGuinness suggestion.

    #18004
    Chazz
    Participant

    can this be used in conjunction with other caching plugins, like w3 total cache?

    #18005
    AITpro Admin
    Keymaster

    The Speed Boost Cache code is Browser Cache code.  So if you are already using Browser Cache code in another caching plugin then you would probably not see any difference in load speeds.  Yes, the Speed Boost Cache code can be used together with other caching plugins cache code, but may be redundant if you already have Browser caching code.  You can of course benchmark test this with YSlow, Firebug and Firephp in Firefox.  Caching plugins cache code should come first in your htaccess file before the Speed Boost Cache code.  Example:  W3TC cache code first then Speed Boost Cache code after the W3TC caching code.

    #20577
    cabdrome
    Participant

    To me is not clear if I can use W3C browser caching or if it is unuseful, or, is useful, how to behave to set both: .htaccess browser cache and w3c cache.

Viewing 15 posts - 1 through 15 (of 35 total)
  • You must be logged in to reply to this topic.