0

I'm trying to send a header based on an environment variable and according to the documentation I'm supposed to use the env condition.

However it is not working. This is my server configuration:

RewriteRule ([^\[]+)(?:\[immutable\].)js$ $1.js [NC,QSA,L,E=immutable]

Header set Cache-Control "immutable, no-transform, public, max-age=31536000" env=immutable

I have verified that if I remove env=immutable, the header sends for all responses.

The expected result is:

  • foo.immutable.js should serve foo.js with the Cache-Control header
  • foo.js should also serve foo.js but without the Cache-Control header

Any ideas as to why it is not working or if there's a way to dump out the environment in the ssl_access_log to debug?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156

1 Answers1

0

Try checking against that REDIRECT_immutable

Since you actually make a substitution, and your Rewrite appears to be in per-directory context, an internal redirect occurs. So your envvar becomes renamed to REDIRECT_immutable by the time mod_headers is actually running on the internal redirect for the final URL.

covener
  • 17,402
  • 2
  • 31
  • 45