From 1322dc60319419fdd3e7799b42fc3ffd9b6da6dd Mon Sep 17 00:00:00 2001 From: Rainer Jung Date: Sun, 24 Jun 2018 10:18:38 +0000 Subject: [PATCH] mod_cache: Handle case of an invalid Expires header value RFC compliant like the case of an Expires time in the past: allow to overwrite the non-caching decision using CacheStoreExpired and respect Cache-Control "max-age" and "s-maxage". Backport of r1833876 from trunk. Submitted by: rjung Reviewed by: rjung, ylavic, rpluem git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1834241 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 5 +++++ STATUS | 10 ---------- modules/cache/mod_cache.c | 7 +++++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 9615f692d1..3faadf5cce 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache 2.4.34 + *) mod_cache: Handle case of an invalid Expires header value RFC compliant + like the case of an Expires time in the past: allow to overwrite the + non-caching decision using CacheStoreExpired and respect Cache-Control + "max-age" and "s-maxage". [Rainer Jung] + *) mod_xml2enc: Fix forwarding of error metadata/responses. PR 62180. [Micha Lenk , Yann Ylavic] diff --git a/STATUS b/STATUS index afa485c21a..c1aaa09225 100644 --- a/STATUS +++ b/STATUS @@ -148,16 +148,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK: svn merge -c 1833827 ^/httpd/httpd/trunk . +1: covener, jim, rjung - *) mod_cache: Handle case of invalid Expires header RFC compliant - like the case of an Expires time in the past. - So allow to overwrite the non-caching decision - using "CacheStoreExpired" and respect Cache-Control - "max-age" and "s-maxage". - trunk patch: http://svn.apache.org/r1833876 - 2.4.x patch: trunk works (needs CHANGES in 2.4) - svn merge -c 1833876 ^/httpd/httpd/trunk . - +1: rjung, ylavic, rpluem - PATCHES PROPOSED TO BACKPORT FROM TRUNK: [ New proposals should be added at the end of the list ] diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 7982776ba8..56a09f5bf5 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -1040,8 +1040,11 @@ static apr_status_t cache_save_filter(ap_filter_t *f, apr_bucket_brigade *in) if (reason) { /* noop */ } - else if (exps != NULL && exp == APR_DATE_BAD) { - /* if a broken Expires header is present, don't cache it */ + else if (!control.s_maxage && !control.max_age && !dconf->store_expired + && exps != NULL && exp == APR_DATE_BAD) { + /* if a broken Expires header is present, don't cache it + * Unless CC: s-maxage or max-age is present + */ reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL); } else if (!control.s_maxage && !control.max_age -- 2.40.0