Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enable compression via .htaccess
- To enable compression via .htaccess file put the following code in your .htaccess file on your server.
- For Apache web servers with mod_gzip
- The code below should be added to your .htaccess file
- <ifModule mod_gzip.c>
- mod_gzip_on Yes
- mod_gzip_dechunk Yes
- mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
- mod_gzip_item_include handler ^cgi-script$
- mod_gzip_item_include mime ^text/.*
- mod_gzip_item_include mime ^application/x-javascript.*
- mod_gzip_item_exclude mime ^image/.*
- mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
- </ifModule>
- You can also compress using DEFLATE mod. To do so, you have to add the following code in .htaccess file. Don’t know how to edit .htaccess file? Read about 3 correct ways to edit .htaccess file.
- For Apache web servers with mod_deflate:
- # BEGIN DEFLATE COMPRESSION
- <IfModule mod_filter.c>
- AddOutputFilterByType DEFLATE "application/atom+xml" \
- "application/javascript" \
- "application/json" \
- "application/ld+json" \
- "application/manifest+json" \
- "application/rdf+xml" \
- "application/rss+xml" \
- "application/schema+json" \
- "application/vnd.geo+json" \
- "application/vnd.ms-fontobject" \
- "application/x-font-ttf" \
- "application/x-javascript" \
- "application/x-web-app-manifest+json" \
- "application/xhtml+xml" \
- "application/xml" \
- "font/eot" \
- "font/opentype" \
- "image/bmp" \
- "image/svg+xml" \
- "image/vnd.microsoft.icon" \
- "image/x-icon" \
- "text/cache-manifest" \
- "text/css" \
- "text/html" \
- "text/javascript" \
- "text/plain" \
- "text/vcard" \
- "text/vnd.rim.location.xloc" \
- "text/vtt" \
- "text/x-component" \
- "text/x-cross-domain-policy" \
- "text/xml"
- </IfModule>
- # END DEFLATE COMPRESSION
- You can use any one code of the above to enable compression on your server. Mod_gzip enables Gzip compression. Mod_deflate compress the output files from your server before it is being served to your visitor. Both has good results with the compression so you can use any one of them.
- How to Tighten WordPress Blog Security using .htaccess
- Enable compression on NGINX web servers
- To enable compression in NGINX web server you will need to add the following code to your config file of your website
- gzip on;
- gzip_comp_level 2;
- gzip_http_version 1.0;
- gzip_proxied any;
- gzip_min_length 1100;
- gzip_buffers 16 8k;
- gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
- # Disable for IE < 6 because there are some known problems
- gzip_disable "MSIE [1-6].(?!.*SV1)";
- # Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
- gzip_vary on;
Add Comment
Please, Sign In to add comment