When we are talking about static data in general (especially when serving a static site). A lot can be optimized by introducing caches on the correct request paths for the client (browser) to cache content.
In this PR, I add Cache-Control headers for Nginx (for 25 days on static content). Assuming the application itself doesn't set any headers.
On static files I normally also do not add access logs. So under Nginx I also add access_log off; for this static location/files (it's up to you to disable access log on static files).
Changes are:
Generic Cache-Control header
Add HTTP Cache-Control headers for static files (in this case only JS, CSS and images like jpg, svg, ico and some media files)..
Forward the host and proto using X-Forwared-Host and X-Forwared-Proto headers, to i dentifiy the original host
The same caching setup for Apache2 it is something like this:
When we are talking about static data in general (especially when serving a static site). A lot can be optimized by introducing caches on the correct request paths for the client (browser) to cache content.
In this PR, I add
Cache-Control
headers for Nginx (for 25 days on static content). Assuming the application itself doesn't set any headers.On static files I normally also do not add access logs. So under Nginx I also add
access_log off;
for this static location/files (it's up to you to disable access log on static files).Changes are:
Cache-Control
headerCache-Control
headers for static files (in this case only JS, CSS and images like jpg, svg, ico and some media files)..X-Forwared-Host
andX-Forwared-Proto
headers, to i dentifiy the original hostThe same caching setup for Apache2 it is something like this:
And for Caddy it is something like this: