Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] default_ttl : New response from origin not stored after expiration.  #10822

Closed
@OwlyCode

Description

@OwlyCode

Hello,

I noticed a strange behavior while playing with HttpCache. Given I install a fresh standard edition, when I enable HttpCache with the following configuration :

protected function getOptions()
{
    return array(
        'debug'       => true,
        'default_ttl' => 10,
    );
}

Here's what I get on the first call (removed some headers for clarity). Everything looks fine :

HTTP/1.1 200 OK
Age: 0
Cache-Control: public, s-maxage=10
Date: Wed, 30 Apr 2014 07:30:04 GMT
X-Content-Digest: ena591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
X-Symfony-Cache: GET /demo/hello/World: miss, store

Hello World

During the time the cached response has not expired, it's fine too :

HTTP/1.1 200 OK
Age: 3
Cache-Control: public, s-maxage=10
Date: Wed, 30 Apr 2014 07:30:07 GMT
x-content-digest: ena591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
X-Symfony-Cache: GET /demo/hello/World: fresh

Hello World

However, when the cached response expires, we always go through the cache and hit the origin. Until the cache is cleared, you'll keep seeing :

HTTP/1.1 200 OK
Cache-Control: no-cache
Date: Wed, 30 Apr 2014 07:30:37 GMT
X-Symfony-Cache: GET /demo/hello/World: stale, invalid

Hello World

I guess that what we would expect is that on the first call after expiration the new response sent by the origin gets stored. It would look like this :

HTTP/1.1 200 OK
Age: 0
Cache-Control: public, s-maxage=10
Date: Wed, 30 Apr 2014 07:34:04 GMT
X-Content-Digest: ena591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
X-Symfony-Cache: GET /demo/hello/World: stale, invalid, store

Hello World

Note : @alquerci already attempted to solve the problem here #8232 and here #9919. It would work but as Fabien stated, we cannot alter the role of the validate() method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions