Report this

What is the reason for this report?

How to setup expire headers in NGINX?

Posted on February 12, 2014

Hi,I want to setup exprire headers for nginx but i don’t know how.I searched but nothing related to this issue.

Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

you didn’t mention what expire header type you need… <br> <br>Nevertheless, this is expire header for images: <br> <br>location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { <br>expires 1y; <br>log_not_found off; <br>} <br> <br>you can add this code to your vhost in /etc/nginx/sites-available/yoursite-vhost <br> <br>I hope that helps

I didn’t noticed I already have included some other things such as css and js files. <br> <br>you can edit whatever you like though

2 Answers

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.