NGINX for the Developer
[ 168 ]
- An HTML file: The Expires header is set to 3 days later than the Date header.
The Cache-Control header has a max-age parameter set to 259200 seconds. - An image: The Expires header is set to Thu, 31 Dec 2037 23:55:55 GMT.
The Cache-Control header has a max-age parameter set to 315360000 seconds.
Just by setting the one directive, expires, in the appropriate location, we can ensure
that our prerendered files are cached locally for as long as they should be.
Changing content on-the-fly
Sometimes it may be helpful post-process what comes from your application.
Maybe you would like to add a string at a certain point in your page to show
which frontend server delivered that page to the client. Or maybe you would
like to perform a transformation on the rendered HTML page. NGINX provides
three modules that could be useful here: the addition module, the sub module,
and the xslt module.