How do I enable browser caching?

I was just reading here about browser caching: https://easyengine.io/wordpress-nginx/tutorials/checklist/

In Apache, I just edit the config file to set browser caching.

What exactly should I do with EasyEngine?

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";
}
2 Likes

Won’t that get overwritten by easy engine?

No, all configuration files created in the folder conf/nginx of a website are automatically added to the nginx configuration. Just use nginx -t and service nginx reload to apply the modification.