-
Notifications
You must be signed in to change notification settings - Fork 84
various tweaks and cleanups #116
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
enabled | ||
------- | ||
|
||
**type**: ``enum`` **default**: ``auto`` **options**: ``true``, ``false``, ``auto`` | ||
**type**: ``enum``, **default**: ``auto``, **options**: ``true``, ``false``, ``auto`` | ||
|
||
Enabled by default if :ref:`ExpressionLanguage is installed <expression language requirement>` | ||
and you have :doc:`configured a proxy client </reference/configuration/proxy-client>`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ Then add the bundle to your application: | |
); | ||
} | ||
|
||
For most features, you also need to :ref:`configure a caching proxy <foshttpcache:proxy-configuration>`. | ||
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. i am still not entirely happy with the interlinking between this doc and the library doc. i also added the prerequisite lines to the feature chapters, but still fear the doc is tough for a beginner. maybe we just need some people to write tutorials in their blogs to get people started on the bundle... 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. I know what you mean. When reading through the docs myself, I half-expected people to start using the bundle without configuring Varnish/Nginx properly and wondering why it doesn't work. ;) I guess we'll just have to wait and see. Your prerequisites headers do help! |
||
|
||
.. _requirements: | ||
|
||
Requirements | ||
|
@@ -72,8 +74,12 @@ later, you need to explicitly add the component: | |
|
||
$ composer require symfony/expression-language | ||
|
||
Now you can configure the bundle under the ``fos_http_cache`` key as explained | ||
in the :doc:`reference/configuration` section. | ||
Configuration | ||
------------- | ||
|
||
Now you can configure the bundle under the ``fos_http_cache`` key. The | ||
:doc:`features` section contains configuration examples, for | ||
a reference see the :doc:`reference/configuration` section. | ||
|
||
Functionality | ||
------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
Flash Message Configuration | ||
=========================== | ||
|
||
TODO | ||
The :doc:`flash message listener <../../features/helpers/flash-message>` is a | ||
tool to avoid rendering the flash message into the content of a page. It is | ||
another building brick for caching pages for logged in users. | ||
|
||
.. code-block:: yaml | ||
|
||
# app/config.yml | ||
fos_http_cache: | ||
flash_message: | ||
enabled: true | ||
name: flashes | ||
path: / | ||
host: null | ||
secure: false | ||
|
||
enabled | ||
------- | ||
|
||
**type**: ``boolean`` **default**: ``false`` | ||
|
||
This event subscriber is disabled by default. You can set enabled to true if | ||
the default values for all options are good for you. When you configure any of | ||
the options, the subscriber is automatically enabled. | ||
|
||
name | ||
---- | ||
|
||
**type**: ``string`` **default**: ``flashes`` | ||
Set the name of the cookie. | ||
|
||
|
||
path | ||
---- | ||
|
||
**type**: ``string`` **default**: ``/`` | ||
|
||
The cookie path to use. | ||
|
||
host | ||
---- | ||
|
||
**type**: ``string`` | ||
|
||
Set the host for the cookie, e.g. to share among subdomains. | ||
|
||
secure | ||
------ | ||
|
||
**type**: ``boolean`` **default**: ``false`` | ||
|
||
Whether the cookie may only be passed through HTTPS. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ cache_control | |
|
||
The configuration contains a number of *rules*. When a request matches the | ||
parameters described in the ``match`` section, the headers as defined under | ||
``headers`` will be set on the response, if they are not already set. | ||
``headers`` will be set on the response, if they are not already set. Rules are | ||
checked in the order specified, where the first match wins. | ||
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. This is already mentioned. 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. but not in the reference i think. i moved a sentence away from the match description, as i think it fits better in each rules section. its not about the match but about the whole rule. 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. In match.rst if I'm not mistaken. 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. Good point. Maybe we should create a rules partial that mentions this. 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. not sure its worth it. this way we can have specific text, instead of a generic text that fits in all context. its not a long text. |
||
|
||
.. code-block:: yaml | ||
|
||
|
@@ -16,7 +17,11 @@ parameters described in the ``match`` section, the headers as defined under | |
match: | ||
host: ^login.example.com$ | ||
headers: | ||
cache_control: { public: false, max_age: 0, s_maxage: 0, last_modified: "-1 hour" } | ||
cache_control: | ||
public: false | ||
max_age: 0 | ||
s_maxage: 0 | ||
last_modified: "-1 hour" | ||
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. reformatting only, to not have horizontal scrolling in the doc. |
||
vary: [Accept-Encoding, Accept-Language] | ||
|
||
# match all actions of a specific controller | ||
|
@@ -25,52 +30,43 @@ parameters described in the ``match`` section, the headers as defined under | |
attributes: { _controller: ^AcmeBundle:Default:.* } | ||
additional_cacheable_status: [400] | ||
headers: | ||
cache_control: { public: true, max_age: 15, s_maxage: 30, last_modified: "-1 hour" } | ||
cache_control: | ||
public: true | ||
max_age: 15 | ||
s_maxage: 30 | ||
last_modified: "-1 hour" | ||
|
||
- | ||
match: | ||
path: ^/$ | ||
headers: | ||
cache_control: { public: true, max_age: 64000, s_maxage: 64000, last_modified: "-1 hour" } | ||
cache_control: | ||
public: true | ||
max_age: 64000 | ||
s_maxage: 64000 | ||
last_modified: "-1 hour" | ||
vary: [Accept-Encoding, Accept-Language] | ||
|
||
# match everything to set defaults | ||
- | ||
match: | ||
path: ^/ | ||
headers: | ||
cache_control: { public: true, max_age: 15, s_maxage: 30, last_modified: "-1 hour" } | ||
cache_control: | ||
public: true | ||
max_age: 15 | ||
s_maxage: 30 | ||
last_modified: "-1 hour" | ||
|
||
rules | ||
----- | ||
|
||
**type**: ``array`` | ||
|
||
A set of cache control rules. | ||
A set of cache control rules consisting of *match* criteria and *header* instructions. | ||
|
||
.. include:: /includes/match.rst | ||
|
||
.. sidebar:: Merging headers | ||
|
||
If the response already has certain cache directives set, they are not | ||
overwritten. The configuration can thus specify defaults that may be | ||
changed by controllers or services that handle the response, or ``@Cache`` | ||
annotations. | ||
|
||
The listener that applies the rules is triggered at priority 10, which | ||
makes it handle before the ``@Cache`` annotations from the | ||
SensioFrameworkExtraBundle are evaluated. Those annotations unconditionally | ||
overwrite cache directives. | ||
|
||
The only exception is responses that *only* have the ``no-cache`` | ||
directive. This is the default value for the cache control and there is no | ||
way to determine if it was manually set. If the full header is only | ||
``no-cache``, the whole cache control is overwritten. | ||
|
||
You can prevent the cache control on specific requests by injecting the | ||
service ``fos_http_cache.event_listener.cache_control`` and calling | ||
``setSkip()`` on it. If this method is called, no cache rules are applied. | ||
|
||
headers | ||
^^^^^^^ | ||
|
||
|
@@ -107,6 +103,25 @@ headers | |
In the ``headers`` section, you define what headers to set on the response if | ||
the request was matched. | ||
|
||
Headers are **merged**. If the response already has certain cache directives | ||
set, they are not overwritten. The configuration can thus specify defaults | ||
that may be changed by controllers or services that handle the response, or | ||
``@Cache`` annotations. | ||
|
||
The listener that applies the rules is triggered at priority 10, which | ||
makes it handle before the ``@Cache`` annotations from the | ||
SensioFrameworkExtraBundle are evaluated. Those annotations unconditionally | ||
overwrite cache directives. | ||
|
||
The only exception is responses that *only* have the ``no-cache`` | ||
directive. This is the default value for the cache control and there is no | ||
way to determine if it was manually set. If the full header is only | ||
``no-cache``, the whole cache control is overwritten. | ||
|
||
You can prevent the cache control on specific requests by injecting the | ||
service ``fos_http_cache.event_listener.cache_control`` and calling | ||
``setSkip()`` on it. If this method is called, no cache rules are applied. | ||
|
||
cache_control | ||
""""""""""""" | ||
|
||
|
@@ -227,7 +242,7 @@ reverse_proxy_ttl | |
|
||
**type**: ``integer`` | ||
|
||
For X-Reverse-Proxy-TTL for Custom Reverse Proxy Time-Outs | ||
Set a X-Reverse-Proxy-TTL header for reverse proxy time-outs not driven by ``s-maxage``. | ||
|
||
By default, reverse proxies use the ``s-maxage`` of your ``Cache-Control`` header | ||
to know how long it should cache a page. But by default, the s-maxage is also | ||
|
@@ -255,7 +270,9 @@ then use on the reverse proxy: | |
- | ||
headers: | ||
reverse_proxy_ttl: 3600 | ||
cache_control: { public: true, s_maxage: 60 } | ||
cache_control: | ||
public: true | ||
s_maxage: 60 | ||
|
||
This example adds the header ``X-Reverse-Proxy-TTL: 3600`` to your responses. | ||
Varnish by default knows nothing about this header. To make this solution work, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
Matching | ||
======== | ||
|
||
Several parts of the configuration use ``match`` sections to limit | ||
configuration to specific requests and responses. Matches are used for | ||
:doc:`caching headers <headers>`, :doc:`invalidation <invalidation>` and | ||
:doc:`tag rules <tags>`. | ||
match | ||
===== | ||
----- | ||
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. regarding https://github.com/FriendsOfSymfony/FOSHttpCacheBundle/pull/116/files#r15554133 : i propose to remove this from here, because its about rules, not about a match section. |
||
|
||
**type**: ``array`` | ||
|
||
Defines the matching part of a :doc:`cache <headers>`, :doc:`invalidation <invalidation>` | ||
or :doc:`tag rule <tags>`. It contains one or more match criteria for | ||
requests. All criteria are regular expressions. They are checked in the order | ||
specified, where the first match wins. | ||
|
||
All matching criteria are regular expressions. For instance: | ||
A match contains one or more match criteria for requests. All matching criteria | ||
are regular expressions. For instance: | ||
|
||
.. code-block:: yaml | ||
|
||
|
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.
reading up on this again it simply makes no sense whatsoever to have a httpOnly cookie that is intended to be used in javascript. removed this option.
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.
👍