-
Notifications
You must be signed in to change notification settings - Fork 84
Allow override of request cache headers #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,21 @@ Set caching headers under the ``cache_control`` configuration section, | |
which consists of a set of rules. When the request matches all criteria under | ||
``match``, the headers under ``headers`` will be set on the response. | ||
|
||
A Response may already have cache headers set, e.g. by the controller method. | ||
By default, the options that already exist are not overwritten, but additional | ||
headers are added. You can force to overwrite the headers globally by setting | ||
``cache_control.defaults.overwrite: true`` to true, or on a per rule basis with | ||
``overwrite: true`` under ``headers``. | ||
|
||
For instance: | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config/config.yml | ||
fos_http_cache: | ||
cache_control: | ||
defaults: | ||
overwrite: true | ||
rules: | ||
# only match login.example.com | ||
- | ||
|
@@ -48,8 +56,9 @@ For instance: | |
# match everything to set defaults | ||
- | ||
match: | ||
path: ^/ | ||
path: ^/ | ||
headers: | ||
overwrite: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ddeboer i am not really happy that this configuration is at the same place as the headers configuration. but i don't see where else we can put it without changing a lot in the data structure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It”s okay with me. If we could change the data structure, what would you propose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if i knew, i would already have proposed something :-) |
||
cache_control: { public: true, max_age: 15, s_maxage: 30 } | ||
last_modified: "-1 hour" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonzalovilaseca i propose that we use the overwrite flag with all headers, not only cache directives but also vary and last-modified (below). otherwise it would need a more specific name. but i think this is the expected - i want to overwrite the things i configure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddeboer btw, no idea why this was previously that complicated - the symfony HeaderBag already does the merge if the second argument is false ("$replace").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu it makes total sense to overwrite both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu Lol, good one. :)