Question

How to add expiry header in NGINX?

Tried to add this one- location ~* .(js|css|png|jpg|jpeg|gif|ico)$ { expires 30d; log_not_found off; }

But it didn’t worked,that stopped the server. Any solution?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Check out the Nginx wiki: <a href=“http://wiki.nginx.org/HttpHeadersModule”>ngx_http_headers_module</a>.

Are there any errors in the error log file? <br><pre>sudo tail /var/log/nginx/error.log</pre>