Adding Expires Headers - Nginx


Can anyone advise me how to add expires headers on server with Nginx? I have instructions for a regular server, but they won’t work under Virtualmin.

This is a Virualmin server running Nginx on CentOS 8.


Depends from your nginx site config

Some examples:
location /mypath/ {
expires max;

location ~* .(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ {
add_header Cache-Control “public”;
add_header X-Frame-Options “SAMEORIGIN”;
expires +1y;

Do “nginx -t” and if ok, reload or restart.
Some examples.

1 Like

I will give this a try after I fix another issue. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.