Cache Control with htaccess FILES MATCH


/ Published in: Apache
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # Cache Control with .htaccess
  2. # from http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html
  3.  
  4. # 3 Month
  5. <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
  6. Header set Cache-Control "max-age=7257600"
  7. </FilesMatch>
  8.  
  9. # 1 Week
  10. <FilesMatch ".(js|css|pdf|txt)$">
  11. Header set Cache-Control "max-age=604800"
  12. </FilesMatch>
  13.  
  14. # 10 Minutes
  15. <FilesMatch ".(html|htm)$">
  16. Header set Cache-Control "max-age=600"
  17. </FilesMatch>
  18.  
  19. # NONE
  20. <FilesMatch ".(pl|php|cgi|spl)$">
  21. Header unset Cache-Control
  22. Header unset Expires
  23. Header unset Last-Modified
  24. FileETag None
  25. Header unset Pragma
  26. </FilesMatch>
  27.  
  28. # TIME CHEAT SHEET
  29. # 300 5 MIN
  30. # 600 10 MIN
  31. # 900 15 MIN
  32. # 1800 30 MIN
  33. # 2700 45 MIN
  34. #
  35. # 3600 1 HR
  36. # 7200 2 HR
  37. # 10800 3 HR
  38. # 14400 4 HR
  39. # 18000 5 HR
  40. # 36000 10 HR
  41. # 39600 11 HR
  42. # 43200 12 HR
  43. # 46800 13 HR
  44. # 50400 14 HR
  45. # 54000 15 HR
  46. # 86400 24 HR
  47. #
  48. # 86400 1 DAY
  49. # 172800 2 DAY
  50. # 259200 3 DAY
  51. # 345600 4 DAY
  52. # 432000 5 DAY
  53. # 518400 6 DAY
  54. # 604800 7 DAY
  55. #
  56. # 604800 1 WEEK
  57. # 1209600 2 WEEK
  58. # 1814400 3 WEEK
  59. # 2419200 4 WEEK
  60. #
  61. # 2419200 1 MONTH (FEBRUARY)
  62. # 2505600 1 MONTH (FEBRUARY LEAP YEAR)
  63. # 2592000 1 MONTH (APRIL, JUNE, SEPTEMBER, NOVEMBER)
  64. # 2678400 1 MONTH (JANUARY, MARCH, MAY, JULY, AUGUST, OCTOBER, DECEMBER)
  65. # 31536000 12 MONTH

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.