tags

Create tag rules in your application configuration to set tags on responses and invalidate them. See the tagging feature chapter for an introduction.

enabled

type: enum, default: auto, options: true, false, auto

Enabled by default if you have configured the cache manager with a proxy client.

If you use a proxy client that does not support banning, cache tagging is not possible. If you leave enabled on auto, tagging will be deactivated.

Enables tag annotations and rules. If you want to use tagging, it is recommended that you set this to true so you are notified of missing dependencies and incompatible proxies:

# app/config/config.yml
fos_http_cache:
    tags:
        enabled: true

rules

type: array

Write your tagging rules by combining a match definition with a tags array. Rules are checked in the order specified, where the first match wins. These tags will be set on the response when all of the following are true:

  1. the HTTP request matches all criteria defined under match
  2. the HTTP request is safe (GET or HEAD)
  3. the HTTP response is considered cacheable (override with additional_cacheable_status and match_response).

When the definition matches an unsafe request (so 2 is false), the tags will be invalidated instead.

match

type: array

A match definition that when met, will execute the rule effect. See match.

tags

type: array

Tags that should be set on responses to safe requests; or invalidated for unsafe requests.

# app/config/config.yml
fos_http_cache:
    tags:
        rules:
            -
                match:
                    path: ^/news
                tags: [news-section]

tag_expressions

type: array

You can dynamically refer to request attributes using expressions. Assume a route /articles/{id}. A request to path /articles/123 will set/invalidate tag articles-123 with the following configuration:

# app/config/config.yml
fos_http_cache:
    tags:
        rules:
            -
                match:
                    path: ^/articles
                tags: [articles]
                tag_expressions: ["'article-'~id"]

The expression has access to all request attributes and the request itself under the name request.

You can combine tags and tag_expression in one rule.