Rakii143

Enable Compresssion

Oct 20th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. Enable compression via .htaccess
  2.  
  3. To enable compression via .htaccess file put the following code in your .htaccess file on your server.
  4.  
  5. For Apache web servers with mod_gzip
  6.  
  7. The code below should be added to your .htaccess file
  8.  
  9. <ifModule mod_gzip.c>
  10. mod_gzip_on Yes
  11. mod_gzip_dechunk Yes
  12. mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
  13. mod_gzip_item_include handler ^cgi-script$
  14. mod_gzip_item_include mime ^text/.*
  15. mod_gzip_item_include mime ^application/x-javascript.*
  16. mod_gzip_item_exclude mime ^image/.*
  17. mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
  18. </ifModule>
  19. 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.
  20.  
  21. For Apache web servers with mod_deflate:
  22.  
  23. # BEGIN DEFLATE COMPRESSION
  24. <IfModule mod_filter.c>
  25. AddOutputFilterByType DEFLATE "application/atom+xml" \
  26. "application/javascript" \
  27. "application/json" \
  28. "application/ld+json" \
  29. "application/manifest+json" \
  30. "application/rdf+xml" \
  31. "application/rss+xml" \
  32. "application/schema+json" \
  33. "application/vnd.geo+json" \
  34. "application/vnd.ms-fontobject" \
  35. "application/x-font-ttf" \
  36. "application/x-javascript" \
  37. "application/x-web-app-manifest+json" \
  38. "application/xhtml+xml" \
  39. "application/xml" \
  40. "font/eot" \
  41. "font/opentype" \
  42. "image/bmp" \
  43. "image/svg+xml" \
  44. "image/vnd.microsoft.icon" \
  45. "image/x-icon" \
  46. "text/cache-manifest" \
  47. "text/css" \
  48. "text/html" \
  49. "text/javascript" \
  50. "text/plain" \
  51. "text/vcard" \
  52. "text/vnd.rim.location.xloc" \
  53. "text/vtt" \
  54. "text/x-component" \
  55. "text/x-cross-domain-policy" \
  56. "text/xml"
  57. </IfModule>
  58. # END DEFLATE COMPRESSION
  59. 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.
  60.  
  61. How to Tighten WordPress Blog Security using .htaccess
  62. Enable compression on NGINX web servers
  63.  
  64. To enable compression in NGINX web server you will need to add the following code to your config file of your website
  65.  
  66. gzip on;
  67. gzip_comp_level 2;
  68. gzip_http_version 1.0;
  69. gzip_proxied any;
  70. gzip_min_length 1100;
  71. gzip_buffers 16 8k;
  72. gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  73.  
  74. # Disable for IE < 6 because there are some known problems
  75. gzip_disable "MSIE [1-6].(?!.*SV1)";
  76.  
  77. # Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
  78. gzip_vary on;
Add Comment
Please, Sign In to add comment