Try this shorter form: location / { location ~ \.(html|htm)$ { # "pragma" is not a valid header here add_header Cache-Control "no-cache, no-store"; try_files $uri @backend; } expires 7d; try_files $uri @backend; }