Quantcast
Channel: EasyEngine Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 12639

How do I enable browser caching?

$
0
0

If you want to allow browser caching for static assets, you just have to add the following code to your website nginx configuration, in /var/www/yourwebsite/conf/nginx/thenameyouwant.conf

location ~* \.(?:css|js|txt)$ {
	expires         1y;
	sendfile        on;
	tcp_nopush      on;
	tcp_nodelay     off;
	add_header      Cache-Control "public";
}

#Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
	expires 1M;
	access_log off;
	add_header Cache-Control "public";
}

location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
	expires         1M;
	sendfile        on;
	tcp_nopush      on;
	tcp_nodelay     off;
	add_header      Cache-Control "public";
}

Viewing all articles
Browse latest Browse all 12639

Trending Articles