I'm using nginx to server my static content, is there a way that I can set the expires headers for every file that meets a specific rule? For example can I set the expires header for all files that have an extension of '.css'?
Tell me more
×
Server Fault is a question and answer site for
professional system and network administrators. It's 100% free, no registration required.
|
I prefer to do a more complete cache header, in addition to some more file extensions. The '?' prefix is a 'non-capturing' mark, nginx won't create a $1. It helps to reduce unnecessary load.
|
|||||||
|
|
|
|||
|
|
|
You can also set the expires to maximum. Here is the directive I use for css and js.
|
|||||||
|
|
If you have one place that is home to all your static files, something like this will do...
The accepted answer caused nginx to not find any of my static files. Not really sure why, but this is a simple alternative. |
|||
|
|