Quantcast
Channel: DavebyDay
Viewing all articles
Browse latest Browse all 53

htaccess per sfruttare la memorizzazione nella cache del browser

$
0
0

Modifichiamo il nostro file .htaccess andando ad aggiungere quanto segue per permettere al browser di memorizzare nella cache i segenti tipi di file: .gif, .png, jpeg, .ico, .js, .css, .swf .

<FilesMatch "\.(?i:gif|jpe?g|png|ico|css|js|swf)$">

  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=172800, public, must-revalidate"
  </IfModule>

</FilesMatch>

oppure possiamo utilizzare anche:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>

 


Viewing all articles
Browse latest Browse all 53