[BlueOnyx:26636] Re: Edit Nginx

Michael Stauber mstauber at blueonyx.it
Tue Dec 5 18:35:40 -05 2023


Hi Colin,

> We are wanting to Expire Headers to web sites on one of our 5210R 
> servers running Nginx.
> 
> Apparently this is done by editing the conf file for nginx but all the 
> conf files say don’t do this! 😊

Yeah, because Nginx is just doing proxy for HTTPs and Apache is serving 
the content anyway. So you don't edit the Nginx configs at all and 
instead configure Apache the way you want it.

 > You need to add the following code:
 >
 > location ~* \.(jpg|jpeg|gif|png|svg)$ {
 >  expires 365d;
 > }
 >
 > location ~* \.(pdf|css|html|js|swf)$ {
 >  expires 3d;
 > }

That advice might be outdated and not worth the effort. For example: It 
lists swf and Flash has been deprecated quite a while ago. Likewise: 
These days pretty much no browser honors 365 days of caching content. 
Settings this globally for the whole server might also not be wise and 
for those Vsites that need different cache control defaults one could 
easily throw in a .htaccess that has the desired rules.

Here are a couple of examples for that:

https://robinroelofsen.com/browser-caching-htaccess-apache

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list