WordPress.org

Ready to get started?Download WordPress

Forums

Batcache
If-Modified-Since request header can cause a Cache-Control negative max-age (1 post)

  1. Weston Ruter
    Member
    Posted 1 year ago #

    We found a peculiar issue where if a request's If-Modified-Since date does not match the cached response's Last-Modified date, it results in a negative Cache-Control max-age, which we found is interpreted by Akamai to cache the response forever (at least in the configuration we're using).

    To reproduce, hit a URL (e.g. a feed) a couple times to ensure Batcache saves the response in the cache:

    $ curl -Gis 'http://local.example.com/tag/lorem/feed/'
    $ curl -Gis 'http://local.example.com/tag/lorem/feed/'

    Example headers returned:

    HTTP/1.1 200 OK
    Date: Thu, 24 Jan 2013 00:30:46 GMT
    Vary: Cookie,Accept-Encoding
    Last-Modified: Wed, 09 Jan 2013 19:38:59 GMT
    Cache-Control: max-age=300, must-revalidate
    ETag: "726c4bddc70a4ccc0d6c0b77abb97e20"
    Content-Length: 3380
    Content-Type: text/xml; charset=UTF-8

    Note the Last-Modified: Wed, 09 Jan 2013 19:38:59 GMT. If you do a request with this time as the If-Modified-Since:

    $ curl -Gis -H "If-Modified-Since: Wed, 09 Jan 2013 19:38:59 GMT" 'http://local.example.com/tag/lorem/feed/'

    You get the 304 response as expected:

    HTTP/1.1 304 Not Modified
    Date: Thu, 24 Jan 2013 00:32:53 GMT
    Vary: Cookie

    But if you try supplying a different date as the If-Modified-Since date:

    $ curl -Gis -H "If-Modified-Since: Wed, 09 Jan 2013 19:00:00 GMT" 'http://local.example.com/tag/lorem/feed/'
    HTTP/1.1 200 OK
    Date: Thu, 24 Jan 2013 00:35:12 GMT
    Vary: Cookie,Accept-Encoding
    Last-Modified: Wed, 09 Jan 2013 19:38:59 GMT
    Cache-Control: max-age=-1227073, must-revalidate
    ETag: "726c4bddc70a4ccc0d6c0b77abb97e20"
    Content-Length: 3380
    Content-Type: text/xml; charset=UTF-8

    Now you get a negative value for the max-age.

    The patch is simply to prevent negative values: https://gist.github.com/4616240

    http://wordpress.org/extend/plugins/batcache/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic