Leverage browser caching for Nginx

leveragingbrowserApa siy Leverage browser caching ? Ini penjelasan singkatnya versi Bahasa Linggis

Leverage browser caching

Reduce the load times of pages by storing commonly used files from your website on your visitors browser.

Reduce page load times for repeat visitors
Particularly effective on websites where users regularly re-visit the same areas of the website

Trus gimana cara implementasinya pada server berbasis Nginx, berikut caranya :

1. Cari file /etc/Nginx/sites-availeable/default atau apabila memiliki lebih dari 1 website pathnya menjadi /etc/Nginx/sites-available/website-satu

2. Kemudian masukkan insert baris berikut pada file tersebut pada no. 1

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
 expires 365d;
 add_header Pragma public;
 add_header Cache-Control "public";
 }
location ~* \.(pdf)$ {
 expires 30d;
 }

versi lengkapnya, seperti dibawah ini :

server {
 listen 80;
 server_name localhost;
location / {
 root /usr/share/nginx/html;
 index index.html index.htm;
 }
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
 expires 365d;
 add_header Pragma public;
 add_header Cache-Control "public";
 }
location ~* \.(pdf)$ {
 expires 30d;
 }
 }

3. Restart Nginx …. dan rasakan bedanya

Website dapat di cek kecepatan loadnya melalui website http://gtmetrix.com

 

Selamat mencoba ….

 

Video Clip Oldies

VanessaCarlton – A Thousand Miles.mpg Lifehouse – Everything.mpg Lifehouse – You and Me.mpg Lifehouse – Blind.mpg Extreme – More Than Words.mpg

Read More »