Home › Forums › BulletProof Security Pro › htaccess caching code – Speed Boost Cache Code
Tagged: Bonus Custom Code, Cache, htaccess cache, htaccess caching, speed boost
- This topic has 34 replies, 15 voices, and was last updated 1 year, 6 months ago by ibiza.
-
AuthorPosts
-
AITpro AdminKeymaster
@ cabdrome – If you have W3TC installed then use W3TC browser caching. Using both W3TC and BPS Speed Boost Browser caching code is redundant – they both do the exact same thing.
jenni101ParticipantHi,
When testing our page load speed with G WMTools, it gives a recommendation for:
Leverage browser caching: Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
Leverage browser caching for the following cacheable resources:
https://www.mysiet.co.nz/…/kleo/assets/font/fontello.woff?94072344
(2 days)When I searched through my BPS custom code, I found this (#ExpiresByType text/html A86400 # Default is 2 days below so the line above is not needed / commented out) in the Speed Boost section:
<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> Please can you explain what exactly I should be editing it to, to increase this default in this code? As GWMTools suggests: "a minimum cache time of one week and preferably up to one year for static assets." many thanks, Jenny
AITpro AdminKeymasterYes. That is correct. That line of code is not necessary/needed.
jenni101ParticipantOK, so if I wanted to increase it to more than the default of 2 day, please can you explain what/how exactly I should be editing it to increase this default in this code? As GWMTools suggests: “a minimum cache time of one week and preferably up to one year for static assets.”
many thanks.
AITpro AdminKeymaster# Time cheat sheet in seconds
# A86400 = 1 day
# A172800 = 2 days
# A2419200 = 1 month
# A4838400 = 2 months
# A29030400 = 1 yearYou can set ExpiresByType for individual file types or you can set the default to any time you want. You would use the cheat sheet above to change the expiration times. Not sure if 1 year is a good idea or not. When the Speed Boost cache code was originally created a lot of research went into it so I assume the optimum ExpiresByType settings are being used. Feel free to change anything you would like to change.
jenni101ParticipantThanks so much – I’ve got it now! Sorry to be so dumb with this…
alexParticipantThere is only 1 Root Custom Code text box where the order of htaccess code is important: CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE.
Hello. Please tell me this is the correct order? or should I change the order? –
<IfModule mod_headers.c> # Using DENY will block all iFrames including iFrames on your own website # Header set X-Frame-Options DENY # Recommended: SAMEORIGIN - iFrames from the same site are allowed - other sites are blocked # Block other sites from displaying your website in iFrames # Protects against Clickjacking Header always append X-Frame-Options SAMEORIGIN # Protects against Drive-by Download attacks # Protects against MIME/Content/Data sniffing Header set X-Content-Type-Options nosniff </IfModule> # BEGIN WEBSITE SPEED BOOST # Time cheat sheet in seconds # A86400 = 1 day # A172800 = 2 days # A2419200 = 1 month # A4838400 = 2 months # A29030400 = 1 year ------------------ ------------------ # END WEBSITE SPEED BOOST
P.S. Can I use Speed Boost Cache Code for another cms? (Joomla, for example)? Thanks for you answers.
AITpro AdminKeymasterYes, that is the correct order for the code. Yes, you can use the Speed Boost Cache code for any other type of website as long as your host server allows/uses htaccess code.
growitsolutionsParticipant[Topic has been merged into this relevant Topic]
Hi, I have been optimising my sites based on feedback from webpagetest.org. All was good until I activated BPS then I lost some of my scoring based on the code below. How do I get this in my .htaccess file please?
Regards
Dave# BEGIN Expires Caching (Leverage Browser Caching) ## <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 2 week" ExpiresByType image/jpeg "access 2 week" ExpiresByType image/gif "access 2 week" ExpiresByType image/png "access 2 week" ExpiresByType text/css "access 2 week" ExpiresByType application/pdf "access 2 week" ExpiresByType text/x-javascript "access 2 week" ExpiresByType application/x-shockwave-flash "access 2 week" ExpiresByType image/x-icon "access 2 week" ExpiresDefault "access 2 week" </IfModule> ## END Expires Caching (Leverage Browser Caching) ## ## BEGIN Enable GZIP Compression ## <IfModule mod_deflate.c> 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 SetOutputFilter DEFLATE </IfModule> ## END Enable GZIP Compression ## ## BEGIN Vary: Accept-Encoding Header ## <IfModule mod_headers.c> <FilesMatch "\.(js|css|xml|gz)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule> ## END Vary: Accept-Encoding Header ##
AITpro AdminKeymaster@ growitsolutions – See the beginning of this forum topic for the steps to add either your htaccess Browser cache code to BPS Custom Code or use the BPS Speed Boost Browser cache code at the beginning of this forum topic.
protectionParticipant[Topic has been merged into this relevant Topic]
Hello –I just upgraded to BPS Pro v 11.9, and got the message:
Older BPS Speed Boost Cache Code was found saved in this BPS Custom Code text box: CUSTOM CODE TOP PHP/PHP.INI HANDLER/CACHE CODE.
When I click the link http://forum.ait-pro.com/forums/topic/htaccess-caching-code-speed-boost-cache-code/, it takes me to the thread that contains speed boost cache code, but the thread was started Aug 16, 2013. Should I assume that this was updated, and that’s the correct code to use? It’s certainly different from the code I currently have, but I don’t want to make assumptions.
Thanks
AITpro AdminKeymaster@ protection – Yes, you are correct. The new Speed Boost Cache Code has been created/updated in the same original Speed Boost Cache Code Forum Topic.
protectionParticipantGot it, thanks!
Vintagepornbay.comParticipantHow to put expiry dates for external (3rd party) image host thumbnails? Like imagebam, imagevenue, pixhost etc..?
AITpro AdminKeymaster@ vintagepornbay – You can only control caching for things (images, etc) that exist on your server. You cannot control caching of 3rd party external resources that are not hosted on your server.
-
AuthorPosts
- You must be logged in to reply to this topic.