StackOverflowNewbie
StackOverflowNewbie

Reputation: 40653

How to unset Cache-Control max-age in .htaccess?

I'm trying to unset Cache-Control's max-age via .htaccess. The following removes Cache-Control entirely:

Header unset Cache-Control

How do I tell it to remove just "max-age?" Thanks.

Upvotes: 1

Views: 3550

Answers (1)

alienhard
alienhard

Reputation: 14712

In Apache 2.2.4 there is a new Header edit action that allows you to do exactly these kind of manipulations.

From the Apache documentation: If this request header exists, its value is transformed according to a regular expression search-and-replace. The value argument is a regular expression, and the replacement is a replacement string, which may contain backreferences.

However, the regex needed would be fairly complicated. Hence I suggest to just use Header set to override the current Cache-Control if you can hardcode the value. Using the set action overrides the previous value containing max-age.

Upvotes: 1

Related Questions