简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM