Sebuahhobi98

cache

Aug 19th, 2020
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. header("Cache-Control: private, max-age=604800 , pre-check=604800 ");
  2. header("Pragma: private");
  3. header("Expires: " . date(DATE_RFC822,strtotime("+2 day")));
  4.  
  5.  
  6. #file .htaccess
  7. ## EXPIRES CACHING ##
  8. <IfModule mod_expires.c>
  9.     ExpiresActive On
  10.     ExpiresByType image/jpg "access 1 year"
  11.     ExpiresByType image/jpeg "access 1 year"
  12.     ExpiresByType image/gif "access 1 year"
  13.     ExpiresByType image/png "access 1 year"
  14.     ExpiresByType text/css "access 1 month"
  15.     ExpiresByType text/html "access 1 month"
  16.     ExpiresByType application/pdf "access 1 month"
  17.     ExpiresByType text/x-javascript "access 1 month"
  18.     ExpiresByType application/x-shockwave-flash "access 1 month"
  19.     ExpiresByType image/x-icon "access 1 year"
  20.     ExpiresDefault "access 1 month"
  21. </IfModule>
  22. ## EXPIRES CACHING ##
  23.  
  24. <IfModule mod_headers.c>
  25.     Header set Connection keep-alive
  26.     <filesmatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$">
  27.         Header set Cache-Control "max-age=2592000, public"
  28.     </filesmatch>
  29.     <filesmatch "\.(jpg|jpeg|png)$">
  30.         Header set Cache-Control "max-age=1209600, public"
  31.     </filesmatch>
  32.     # css and js should use private for proxy caching https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
  33.    <filesmatch "\.(css)$">
  34.         Header set Cache-Control "max-age=31536000, private"
  35.     </filesmatch>
  36.     <filesmatch "\.(js)$">
  37.         Header set Cache-Control "max-age=1209600, private"
  38.     </filesmatch>
  39.     <filesMatch "\.(x?html?|php)$">
  40.         Header set Cache-Control "max-age=600, private, must-revalidate"
  41.       </filesMatch>
  42. </IfModule>
Add Comment
Please, Sign In to add comment