Home › Forums › BulletProof Security Pro › Gzip compression – custom .htaccess code
- This topic has 8 replies, 3 voices, and was last updated 7 years, 8 months ago by
Joseph Lee.
-
AuthorPosts
-
Chris Moon
ParticipantEd,
I ran a GTmetrix test on my site and was advised to add Gzip compression to speed it up
and this is the code I was told to add to my .htaccess file:
# compress text, HTML, JavaScript, CSS, and XML 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 # remove browser bugs BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Header append Vary User-Agent
Got two questions:
1. Will adding this compromise security on my site?
2. Which .htaccess file should it be added to?regards,
Chris MoonAITpro Admin
KeymasterNope, adding cache code will not compromise or affect your security in any way. This caching code is similar to our Speed Boost cache code in the link below.
http://forum.ait-pro.com/forums/topic/htaccess-caching-code-speed-boost-cache-code/
You can either use this cache code or the Speed Boost cache code and follow the instructions in the link above to add this code to BPS Custom Code.
Chris Moon
ParticipantThanks Ed I’ll try your speed boost code
AITpro Admin
KeymasterYep, works great on all our sites. We had a lot of issues with caching plugins in the past so we needed and created a solution that would not cause any website problems for us.
Joseph Lee
ParticipantI have a question about this: “You can either use this cache code or the Speed Boost cache code…” http://forum.ait-pro.com/forums/topic/gzip-compression-custom-htaccess-code/#post-12923. Does that mean I should remove the BPS Browser Speed Boost Code if I add the “Remove Browser Bugs” code? Or, does that mean I have to choose between BPS Browser Speed Boost and Gzip?
# remove browser bugs BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html Header append Vary User-Agent
AITpro Admin
KeymasterIt means that the BPS Speed Boost Cache code already contains that code so adding it twice would be redundant. The code below is at the bottom of the BPS Speed Boost Cache code and is the same code/does the exact same thing. It is always possible to add additional conditions to any code, but you probably do not want to use duplicate/redundant code just in case it causes some sort of performance problem.
# 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
Joseph Lee
ParticipantAh, I thank you. I had tried to study all of that a bit but had missed that redundancy!
One more question: Do I only need to be concerned about ‘gzip-only-text/html’ and just ignore these others?
text/plain
text/xml
text/css
text/javascriptI ask because I plan to add this as suggested by the Zen Cache plugin and it has those others in it:
<IfModule deflate_module> <IfModule filter_module> AddOutputFilterByType DEFLATE text/plain text/html AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript 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 </IfModule> </IfModule>
AITpro Admin
KeymasterFor the problematic browser section of code you do not need to add anything else. The BPS Speed Boost Cache code has all of the standard content types, but you can add additional content types or you can mix and match or you can roll your own. ie use some of the BPS Speed Boost Cache code and not other portions of it and instead use your own caching code.
http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
Description: Compress content before it is delivered to the client Status: Extension Module Identifier: deflate_module Source File: mod_deflate.c Summary
The
mod_deflate
module provides theDEFLATE
output filter that allows output from your server to be compressed before being sent to the client over the network.Joseph Lee
ParticipantOnce again I am impressed and pleased to discover BPS already had me covered. It just took me a while to catch on.
Many thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.