Duplicate max-age header

apache-2.4cachePROXYproxypass

I'm using Apache 2.4.25 to expose a number of back-end services using proxy pass. Apache also sets the cache control headers based on mime type. The current cache configuration looks like this:

ExpiresActive on
ExpiresDefault "now"
ExpiresByType text/html "now"
ExpiresByType image/gif "access plus 120 minutes"
ExpiresByType image/jpeg "access plus 120 minutes"
ExpiresByType image/png "access plus 120 minutes"
ExpiresByType text/css "access plus 60 minutes"
ExpiresByType text/javascript "access plus 60 minutes"
ExpiresByType application/x-javascript "access plus 60 minutes"
ExpiresByType text/xml "access plus 60 minutes"
ExpiresByType application/javascript "access plus 60 minutes"
ExpiresByType application/x-font-ttf "access plus 30 days"
ExpiresByType application/x-font-woff "access plus 30 days"
ExpiresByType application/x-font-eot "access plus 30 days"
ExpiresByType application/x-font-svg "access plus 30 days"

However, one of the back-end services is also setting the cache-control max-age header. This is causing the response header to contain two max-age settings.

Duplicate max-agent values as seen in Chrome

How does the browser react when presented with two max-age settings with different values? Also, is it possible to check for an existing cache-control header before adding the default?

Best Answer

Use Header "set" instead of Header "add" if you don't want accidental duplicates due to backend sending the same header.

Related Topic