Home › Forums › BulletProof Security Free › WP Super Cache – WP Super Cache htaccess code, Custom Code
- This topic has 82 replies, 8 voices, and was last updated 8 years ago by
AITpro Admin.
-
AuthorPosts
-
AITpro Admin
KeymasterI believe the garbage collection was not working correctly for just the cached files that had been corrupted and that were displaying blank pages, which would actually be what you would want to happen, but it was failing for some reason due to whatever corrupted the files in the first place. All other stale cached files that were not corrupted were being successfully deleted and recreated by garbage collection. I will look into this issue again in about a week.
Young Master
ParticipantI think the temporarily solution for now is to empty cache regularly until we figure out how to resolve this matter.
AITpro Admin
KeymasterGive this code a test drive – do benchmark tests with Firefox, Firebug, Firephp and Yslow. 😉
I recommend that each person test using no ETags by commenting out all the ETag lines of .htaccess code below and benchmark website performance, then benchmark test using Header unset and FileETag none and then benchmark test using FileETag MTime Size. Whichever one makes your website perform the fastest is the one you want to use. On Go Daddy it seems that using Header unset ETag and FileETag none is slightly faster in milliseconds.
1. Copy the Speed Boost .htaccess code into this Custom Code text box: CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE
2. Click the Save Root Custom Code button.
3. Go to the BPS Security Modes page and click the Root Folder BulletProof Mode Activate button.NOTES: If you are using a php/php.ini handler in your root .htaccess file then be sure to copy that php/php.ini .htaccess code directly above this caching code. If you are using a caching plugin that creates .htaccess caching code then you can also add that plugin’s caching code directly above this Speed Boost caching code.
# 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 #FileETag MTime Size # Remove the ETag (entity tag) response header field Header unset ETag FileETag none <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpg A4838400 ExpiresByType image/gif A4838400 ExpiresByType image/jpeg A4838400 ExpiresByType image/png A4838400 ExpiresByType video/webm A4838400 ExpiresByType application/x-shockwave-flash A4838400 ExpiresByType application/x-javascript A4838400 ExpiresByType application/javascript A4838400 ExpiresByType text/javascript A4838400 ExpiresByType text/css A4838400 #ExpiresByType text/html A86400 # Default is 2 days below so the line above is not needed / commented out ExpiresDefault A172800 </IfModule> <IfModule mod_headers.c> <FilesMatch "\.(js|css|flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|gif|jpg|jpeg|png|swf)$"> 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> # Insert filters AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-httpd-fastphp 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
Young Master
ParticipantHolly cow!!! Where did you get this? Did you use this code on this forum? I have done performance test on this forum and I have never seen anyone score A in Yslow without using CDN.
AITpro Admin
KeymasterYep, this code is being used in the Forum and all other AITpro websites. I have some problems with the custom AITpro Theme on other sites that is killing overall performance, but still the speed boost was very significant on the other sites. The custom AITpro Theme needs core coding work to fix the issues with it. Also the Dynamic Drive fancy jQuery menus used in the custom AITpro Theme needs some optimization work.
I took about 4 hours this morning to research, create and benchmark this code. I found the WordPress specific mod_deflate code: http://codex.wordpress.org/Output_Compression on the WordPress site in the link below. It is designed specifically with WordPress in mind (works for any site type of course) for Output Compression and makes a huge difference in speed.
Young Master
ParticipantNice…but there is something I dont understand about this code below
#ExpiresByType text/html A86400 # Default is 2 days below so the line above is not needed / commented out ExpiresDefault A172800
Why did you use ExpiresDefault in text/html instead of ExpiresByType?
AITpro Admin
KeymasterExpiresDefault includes any file type that is not specifically defined in any of the above “file type” rules so that would include html files since the html line of code is commented out.
It was just a personal choice so I left the code commented out with an explanation so that if someone else wanted to instead use the commented out line then they could uncomment it and use it to specifically expire html files after 1 day.
The default expiration is 2 days and that would include html files. A86400 equals 1 day so if you instead want to have html files expire after 1 day then uncomment that line of code. The choice is up to you.
Young Master
ParticipantAfter uncomment ExpiresByType text/html, do I need to comment the ExpiresDefault line? Did you test this code with WP Super Cache?
silas88
ParticipantYou might find this code of interest. An option in my cpanel adds it to my htaccess (at least i think that’s where it came from – don’t quite recal now!).
<IfModule mod_deflate.c> AddOutPutFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript <IfModule mod_setenvif.c> # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 # the above regex won't work. You can use the following # workaround to get the desired effect: BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary </IfModule> <IfModule mod_headers.c> # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule>
____________________________________
I just checked out how old Netscape 4.08 is here https: //en.wikipedia.org/wiki/Netscape_%28web_browser%29
It looks like it’s from 1997 so I’m going to forget about it and delete those lines.
___________________________________I’m starting to wonder about that BrowserMatch code. I think I must have found it on askapache or similar, unfortunately i don’t have a reference link for it in my htaccess.
Anyway I think it’s out of date and therefore suspect.
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 # the above regex won't work. You can use the following # workaround to get the desired effect: BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
It refers to Apache 2.0.48. My web host is on Apache 2.2.21.
__________________________________
Ok, I think I found my original source for the code – it looks like it’s from the Apache documentation.
Here is a link http: //www1.nemac.unca.edu/manual/mod/mod_deflate.html
I also came across this code section# Don’t compress already-compressed files SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .(?:avi|mov|mp3|mp4|rm|flv|swf|mp?g)$ no-gzip dont-vary SetEnvIfNoCase Request_URI .pdf$ no-gzip dont-vary
AITpro Admin
Keymaster@ Young Master – No, do NOT comment out ExpiresDefault directive because they do 2 completely different things and are 2 completely different directives.
ExpiresByType text/html A86400 – means set the expiration time of html files to 1 day.
ExpiresDefault A172800 – means any file types that do NOT have an expiration time set in an ExpiresByType directive expire after 2 days.@ silas88 – Yep, the code you posted is outdated. My obvious recommendation is to use the mmmkay! code. 😉 The most current version of Apache is 2.4.4.
silas88
Participant@AITpro Admin,
Thanks – I definitely have looked at yours, I’ll borrow as much of it as I can! 😉
Your Browsermatch code is basically the same except that mine (probably from the Apache documentation) includes the ‘if’ checks.
Otherwise the main differences that I noted were the inclusion of the Deflate lines which are in my htaccess in my user root i.e /home/user/ . I have always assumed that the htaccess in my user root would be applied to all my domains i.e /home/user/public_html/domain1/ etc.
I hope my assumption is correct.
I have some additional code in my root htaccess for mod_gzip. I also borrowed that from somewhere, it’s headed “Apache configuration directives for mod_gzip 1.3.26.1a”.
Here is a quote from the Apache documentation I linked to earlier
At first we probe for a User-Agent string that indicates a Netscape Navigator version of 4.x. These versions cannot handle compression of types other than text/html. The versions 4.06, 4.07 and 4.08 also have problems with decompressing html files. Thus, we completely turn off the deflate filter for them.The third BrowserMatch directive fixes the guessed identity of the user agent, because the Microsoft Internet Explorer identifies itself also as “Mozilla/4” but is actually able to handle requested compression. Therefore we match against the additional string “MSIE” (\b means “word boundary”) in the User-Agent Header and turn off the restrictions defined before.
The user/agent for MSIE9 is Mozilla/4.0 and for MSIE10 is Mozilla/5.0.I am not sure what compressions modern browsers like MSI10 and similar can handle.
some more homework on compression …
http: //www.vervestudios.co/projects/compression-tests/results
http: //zoompf.com/2012/02/lose-the-wait-http-compression
Young Master
ParticipantThanks @AITPro Admin. I will give a try of this code. Hopefully it will work just fine with WP Super Cache.
Young Master
ParticipantAm sick and tired of WP Super Cache. Tested the code with WPSC but the problem is still there. Today my site just displayed blank pages over 5 times. According to my observations the problem occurs only at the time when the site is receiving a huge traffic and it does not occur at times when the site doesnt receive huge traffic.
AITpro Admin
KeymasterYep, there is still going to be a conflict with the .htaccess code and what WPSC is doing. I suspect that that the conflict is with mod_deflate. At least that seems like the most obvious thing to look at first. Once I get BPS Pro 6.0 released then I will look into this some more.
Young Master
ParticipantAm afraid the code is breaking xml sitemap from submitting contents to search engines. I have written more than 9 articles since monday but untill today none new posts have been submitted to either google or bing. Sometimes it fails to ping search engines when I publish a post and even when it succeeds to ping the search it submits nothing.
-
AuthorPosts
- You must be logged in to reply to this topic.