How to setup expire headers in NGINX?

February 12, 2014 5.4k views
Hi,I want to setup exprire headers for nginx but i don't know how.I searched but nothing related to this issue. Thanks
1 comment
4 Answers
you didn't mention what expire header type you need...

Nevertheless, this is expire header for images:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1y;
log_not_found off;

you can add this code to your vhost in /etc/nginx/sites-available/yoursite-vhost

I hope that helps
I didn't noticed I already have included some other things such as css and js files.

you can edit whatever you like though
Have another answer? Share your knowledge.