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.
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:
# 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:
- the HTTP request matches all criteria defined under match
- the HTTP request is safe (GET or HEAD)
- 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.
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.