Post

How to control browser caching

In Uncategorized on December 30, 2010 by Chandra Saputra

Sebuah tulisan niubi kembali dituliskan. Seperti yang saya tuliskan kemarin tentang web performance, kali ini akan saya sharing tentang browser caching. Browser caching berfungsi untuk menyimpan segala atribut dan data pada browsernya. Hal ini menjadikan sewaktu kita mengakses web tersebut lebih cepat dan menghemat bandwith *paling :D

Adapun tips dan triknya antara lain :

  • Pastikan modul berikut telah di enable :
Module expires already enabled
  • Jika server anda centos pastikan bahwa konfigurasi http anda meload library mod_expires dibawah ini, untuk file konfigurasinya bisa anda dapatkan di /etc/httpd/conf/httpd.conf
  • LoadModule expires_module modules/mod_expires.so
    

    Jika bertanda # maka hilangkan tanda tersebut

  • Tambahkan script ini pada file .htaccess anda
  • ExpiresActive on
    ExpiresByType application/javascript "access plus 1 months"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 months"
    
  • Aktifkan pula rerwite engine untuk direktori anda (jika perlu)
  • # Turn on URL rewriting
    RewriteEngine On
    
    # Installation directory
    RewriteBase /
    
    # Protect application and system files from being viewed
    RewriteRule ^(application|modules|system) - [F,L]
    
    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all other URLs to index.php/URL
    RewriteRule .* index.php/$0 [PT,L]
    

Sumber : Klik di sini

Demikian Informasi dari saya, semoga bermanfaat. Mohon maaf jika ada salah2 kata.. :D

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.