PHP Cara Setting .htaccess Cache Images and Fonts

PHP Cara Setting .htaccess Cache Images and Fonts

Pada artikel kali ini kita akan mencoba untuk setting setting .htaccess untuk cache images dan fonts.

Pertama kita buat dulu sebuah file .htaccess dan masukkan kode berikut.

 

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/font-woff "access plus 1 year"
    ExpiresByType application/font-woff2 "access plus 1 year"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/x-javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 2 days"
</IfModule>

 

Untuk jangka waktu cache time nya bisa disesuaikan sendiri sesuai dengan keinginan kalian.

Selamat mencoba.