Skip to content

Support stale-while-revalidate and stale-if-error cache-control extensions #3421

@akira28

Description

@akira28

Description
At the moment neither stale-while-revalidate nor stale-if-error are supported natively by Api Platform HTTP cache system. These extensions are described in this RFC and supported in Symfony through SensioFrameworkExtraBundle

Example
Using this configuration:

api_platform:
    http_cache:
        max_age: 0
        shared_max_age: 3600
        stale_while_revalidate: 15
        stale_if_error: 30

or using the cacheHeaders attribute in the entity:

/**
 * @ApiResource(cacheHeaders={"max_age"=0, "shared_max_age"=3600, "stale_while_revalidate"=15, "stale_if_error"=30})
 */

would produce this cache-control:
max-age=0, s-maxage=3600, stale-while-revalidate=15, stale-if-error=30

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions