-
Notifications
You must be signed in to change notification settings - Fork 61
Symfony HttpCache listener for custom ttl header #214
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
By default, the caching proxy looks at the ``s-maxage`` instruction in the | ||
``Cache-Control`` header to know for how long it should cache a page. But the | ||
``Cache-Control`` header is also sent to the client. Any caches on the Internet, | ||
for example the Internet provider or from a cooperate network might look at | ||
``s-maxage`` and cache the page. This can be a problem, notably when you do | ||
:doc:`explicit cache invalidation </cache-invalidator>`. In that | ||
scenario, you want your caching proxy to keep a page in cache for a long time, | ||
but caches outside your control must not keep the page for a long duration. | ||
|
||
One option could be to set a high ``s-maxage`` for the proxy and simply rewrite | ||
the response to remove or reduce the ``s-maxage``. This is not a good solution | ||
however, as you start to duplicate your caching rule definitions. | ||
|
||
The solution to this issue provided here is to use a separate, different header | ||
called ``X-Reverse-Proxy-TTL`` that controls the TTL of the caching proxy to | ||
keep ``s-maxage`` for other proxies. Because this is not a standard feature, | ||
you need to add configuration to your caching proxy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ github | |
vcl | ||
fos | ||
Vcl | ||
inline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this was rather puzzling me with my varnish 3 locally. i think it does make sense to use an environment over a constant here.
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.
Should we then remove the constant and getter for
VARNISH_VERSION
? I prefer to keep them, as it’s consistent this way with the other config params. I agree that you’ll typically set the Varnish version through an env var. By the way, testing against multiple Varnish versions is most useful for library/framework code; and less relevant for users testing an app against their caching setup.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.
i am not removing anything except wrong documentation. i added documentation for the environment variable and keep the getter that is using the env variable. we use the env variable both in VarnishTestCase and tests/bootstrap.php
we could alternatively look at both or have tests/bootstrap.php copy the env variable into a constant. but that all feels a bit clumsy and just as confusing.