×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Apache
Posted by: Web Designer
Added: Feb 9, 2017 10:18 AM
Modified: Feb 9, 2017 10:19 AM
Views: 13
Optimize speed page by enable cache on www server.
  1. ###### Paste code at the end of htaccess file ######
  2.  
  3. ###### For apache servers paste code: ######
  4.  
  5. ## EXPIRES CACHING ##
  6. <IfModule mod_expires.c>
  7. ExpiresActive On
  8. ExpiresByType image/jpg "access 1 year"
  9. ExpiresByType image/jpeg "access 1 year"
  10. ExpiresByType image/gif "access 1 year"
  11. ExpiresByType image/png "access 1 year"
  12. ExpiresByType text/css "access 1 month"
  13. ExpiresByType text/html "access 1 month"
  14. ExpiresByType application/pdf "access 1 month"
  15. ExpiresByType text/x-javascript "access 1 month"
  16. ExpiresByType application/x-shockwave-flash "access 1 month"
  17. ExpiresByType image/x-icon "access 1 year"
  18. ExpiresDefault "access 1 month"
  19. </IfModule>
  20.  
  21. ###### If there is no results, try code below (max-age means amount of seconds - you can set any other value) ######
  22. <filesMatch ".(ico|pdf|flv|gif|jpg|svg|jpeg|png|js|css|swf)$">
  23. Header set Cache-Control "max-age=846000, public"
  24. </filesMatch>
  25.  
  26. ###### For Nginx servers paste code: ######
  27. location ~* \.(js|css|png|jpg|svg|jpeg|gif|ico)$ {
  28.     expires 2d;
  29.     add_header Cache-Control "public, no-transform";
  30. }
Comments disabled