How to overcome Add Expires Headers on a NGINX Server?
As I understand cPanel supports some features on a NGINX Server.
How to manage and solve Add Expires Headers in this case?
Where to put ?
location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
}
location ~* \.(pdf|css|html|js|swf)$ {
expires 2d;
}
Verification shows very bad result
Add Expires headers 56
-
Howdy, Are you sure there isn't any other block in configuration that might later be matching those same URLs and applying an expires header of 56d? As is, I don't really see anything off the top of my head that would make these conditions not match for URLs they would appear to match other than missing context. Apologies in advance if I misunderstand you. Perhaps it would be of value for you to use a location match configuration tester website for your NGINX configuration? Several exist online that I saw when looking around in response to your posting here (search term "nginx location match tester"). Also, as a side note, are you sure the `Expires` header is the best approach here for static content? Generally this is considered an outdated technique for ensuring static content gets cached compared to using Cache-control
headers withmax-age
set. I say this because modern browsers will in fact ignore theExpires
header in favor of this other technique when both are present in response headers.0 -
Can you inform us about official steps to make NGINX settings inside cPanel which will not break website? I see it is limited setting: NGINX with Reverse Proxy | cPanel & WHM Documentation 0 -
The "Configuration files" link at NGINX with Reverse Proxy | cPanel & WHM Documentation gives more detail on how you can edit the configuration in a way that will not get overwritten by cPanel updates. 0
Please sign in to leave a comment.
Comments
3 comments