On Thu, Feb 26, 2015 at 1:00 PM, Yann Ylavic <ylavic.dev@xxxxxxxxx> wrote: > On Thu, Feb 26, 2015 at 10:21 AM, Paul Beckett <paul_beckett@xxxxxxxxxxx> wrote: >> Is there any way to restrict what HTTP response codes are cached by Apache, >> ideally I would like to only cache 200,301,302 responses. > > It is not possible to specify some particular status mod_cache would > or not cache, it is solely controlled by the relevant Cache-Control > and Expires headers. > (Note that 301 will not be cached unless "forced" by these headers). Hmm, I forgot about the RFC and mod_cache's code (and I meant 302 above)... Actually, mod_cache won't cache anything but 200, 203, 206, 300, 301 or 410 (as per RFC), unless otherwise specified by Cache-Control (public, ...) or Expires (future date) headers. So you probably have one of these in your response (mod_expires sets Expires if you use it, but it has been fixed in 2.4.10 not to for 4xx/5xx responses precisely, and you are already in 2.4.10...). The mod_headers rules below should not be needed then, what are the headers associated with the 404? > > You could use some mod_headers rule(s) like : > Header merge Cache-Control private "expr=%{REQUEST_STATUS} == 404" > Header merge Pragma no-cache "expr=%{REQUEST_STATUS} == 404" > to prevent mod_cache (but also other caches down the chain) from > caching eg. 404s. > > Regards, > Yann. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx