Fare il leverage del caching del browser generalmente significa che puoi impostare quanto i browser devono conservare immagini, CSS e JS nella memoria locale. In questo modo l’utente scaricherà meno dati mentre naviga sulle pagine - questo di conseguenza andrà a velocizzare l’esperienza di navigazione del sito.
Per abilitarlo, aggiungi le seguenti linee al tuo file .htaccess:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
|
Puoi creare/modificare il file .htaccess file either via FTP o utilizzando lo strumento Gestione File del tuo cPanel.