Setting Cache Website di Browser Cache dan Compress Website dengan Htaccess


Sup temen-temen Programmer,
Kali ini sedikit tips meringankan kinerja hosting dan mempercepat load website temen-temen dengan memanfaatkan script .htaccess dan Cache di Browser para penikmat website temen-temen.

Awalnya gue iseng-iseng cek kinerja load page website yang gue buat untuk organisasi pengusaha di Indonesia make aplikasi yang di rilis oleh google ini :

https://developers.google.com/speed/pagespeed/insights/

Dari situ gue nemu banyak kekurangan dalam hal load website buatan gue yang buat jadi agak lambat huhuhu :'(

Akhirnya dengan kemauan kuat gue akhirnya nyari-nyari solusi sana-sini dan nemu lah gue 2 buah script yang lumayan buat di tambain ke script htaccess gue! Nah ini deh scriptnya.

#Compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
#End compression

Copy Script diatas ke .htaccess temen-temen yang nanti berguna buat compress file text, html, javascript, css dan xml. Jadi agak ngeringanin kerja server, tapi ada 1 syarat yg harus dipenuhin, MOD_DEFLATE di system hostingnya harus aktif! kalo ga, ga bakal work! Dan buat nyoba udah bener engganya bisa make Page Speed Google tadi. heuheuheu.

Nah, sekarang kita mau ngadalin Cache Website via Cache Browser, heuheuheu biar ga terus terusan load dari hosting. buat hosting murah mah nih bagus, tapi ya harus make htaccess.
## 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 text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

Copy Scriptnya dan paste ke .htaccess temen-temen dan voila Website temen-temen lebih cepet loadnya dari yang tadi. See ya!


Next Post Previous Post