Double "cache-control" header on nginx
-
Hi,
I would have replied to this post, but the topic is closed so I’m opening a new one.
If using W3 on nginx, there’s an small issue with the cache-control headers. If you enable ‘Set expires header’ and ‘Set cache control header’ for static files under the Browser Cache options, then you end up with two cache-control headers in the response. From what I’ve read, it’s permitted in the spec to have more than one Cache-Ccontrol header, but it can cause confusion. For example, CloudFlare will only read the first one.
The reason it happens is because you’re setting the ‘expires’ directive and adding a cache control header (e.g. add_header Cache-Control “public”). Nginx will add a Cache-Control header automatically when using the ‘expires’ directive, so the add_header line in nginx.conf creates the duplicate.
For those looking for a workaround, you can simply disable the ‘Set expires header’ option in the plugin settings and you will then get just one cache-control response header.
- The topic ‘Double "cache-control" header on nginx’ is closed to new replies.