Ruediger Pluem wrote:
>
> On 01/15/2007 01:56 PM, Bart van der Schans wrote:
>> In r463496 the following check was added to mod_cache.c :
>>
>> else if (exp != APR_DATE_BAD && exp < r->request_time)
>> {
>> /* if a Expires header is in the past, don't cache it */
>> reason = "Expires header already expired, not cacheable";
>> }
>>
>> This check fails to correctly identify the expires header "Thu, 01 Jan
>> 1970 00:00:00 GMT". The apr_date_parse_http function(exps) returns
>> (apr_time_t)0 which is equal to APR_DATE_BAD, but it should recognize it
>> as an already expired header. Is there a way to distinct between
>> APR_DATE_BAD and the unix epoch? Or is that considered a bad date?
>
> I would say 0 is not a bad day. But if this is a bug it is an APR(-util) bug.
> Thus I forward it to the apr dev list.
>
> Regards
>
> RĂ¼diger
>
Looking at it more, the previous check it's also useless. Attempted patch...
--
Davi Arnaut
Index: modules/cache/mod_cache.c
===================================================================
--- modules/cache/mod_cache.c (revision 497262)
+++ modules/cache/mod_cache.c (working copy)
@@ -372,13 +372,8 @@
exps = apr_table_get(r->headers_out, "Expires");
}
if (exps != NULL) {
- if (APR_DATE_BAD == (exp = apr_date_parse_http(exps))) {
- exps = NULL;
- }
+ exp = apr_date_parse_http(exps);
}
- else {
- exp = APR_DATE_BAD;
- }
/* read the last-modified date; if the date is bad, then delete it */
lastmods = apr_table_get(r->err_headers_out, "Last-Modified");
@@ -424,21 +419,24 @@
*/
reason = apr_psprintf(p, "Response status %d", r->status);
}
+ else if (r->args && exps == NULL) {
+ /* if query string present but no expiration time, don't cache it
+ * (RFC 2616/13.9)
+ */
+ reason = "Query string present but no expires header";
+ }
+ /* XXX: APR_DATE_BAD (0) is a valid date */
else if (exps != NULL && exp == APR_DATE_BAD) {
/* if a broken Expires header is present, don't cache it */
reason = apr_pstrcat(p, "Broken expires header: ", exps, NULL);
}
- else if (exp != APR_DATE_BAD && exp < r->request_time)
+ else if (exps != NULL && exp < r->request_time)
{
- /* if a Expires header is in the past, don't cache it */
+ /* if a Expires header is in the past, don't cache it.
+ * it may also be a broken header too, anyway.. we won't cache it
+ */
reason = "Expires header already expired, not cacheable";
}
- else if (r->args && exps == NULL) {
- /* if query string present but no expiration time, don't cache it
- * (RFC 2616/13.9)
- */
- reason = "Query string present but no expires header";
- }
else if (r->status == HTTP_NOT_MODIFIED &&
!cache->handle && !cache->stale_handle) {
/* if the server said 304 Not Modified but we have no cache
@@ -686,7 +684,7 @@
* else
* expire date = date + defaultexpire
*/
- if (exp == APR_DATE_BAD) {
+ if (exps == NULL) {
char expire_hdr[APR_RFC822_DATE_LEN];
/* if lastmod == date then you get 0*conf->factor which results in