-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.0][HttpFoundation] Improved Cache-Control header when no-cache is sent #6037
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
Conversation
I'm not sure what Travis wants or how can I test it, any help in running the tests is greatly appreciated. Thanks! |
Travis failures are external, someone messed-up an upgrade or something. Seems good to me, not sure if IE8 will work as expected. But I'm not able to test this currently. |
I've read that as well as : http://support.microsoft.com/kb/234067 Thanks. |
Seems that using AppCache breaks things after applying this.
|
I've changed the Expiry time to 1st of January 2000 as -1 doesn't really seem a valid option and it's back far enough in the past. |
from http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
|
||
$this->headers['pragma'] = array('no-cache'); | ||
$this->headerNames['pragma'] = 'Pragma'; | ||
} |
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 would have used parent::set('expires', 0)
and parent::set('pragma', 'no-cache')
instead.
The patch is not enough. If the computed value is not |
I've moved the logic to the |
Also, while I understand that Request and Response are different 'scopes', I'm not sure why Symfony Standard does this: $this->setProtocolVersion('1.0'); in the constructor of Response and then not change it to the supported/requested by client protocol. I've noticed it while testing with Firefox, I'd always get a HTTP/1.0 response when I'm in fact sending a HTTP/1.1 request. Could this be considered as bug as well? |
@dlsniper This has been fixed in 2.1. |
@@ -236,6 +236,10 @@ public function getDate($key, \DateTime $default = null) | |||
return $default; | |||
} | |||
|
|||
if (-1 == $value || 0 === $value) { |
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 change should be reverted as it breaks BC. This can be discussed for the master branch though.
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.
With the move of the code that relied on this I'll remove this but indeed we should talk about this in either master or 2.1 as it's not consistent between the values that are sent by the framework and what can sent by the user.
I'll squash this when you think it's ready to be merged then I'll make a PR for 2.1/master branch if needed. |
not really sure if this is related but as it might I want to mention liip/LiipImagineBundle#124 |
@@ -226,7 +226,7 @@ public function remove($key) | |||
* @param string $key The parameter key | |||
* @param \DateTime $default The default value | |||
* | |||
* @return \DateTime The filtered value | |||
* @return null|\DateTime The filtered value |
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 be reverted
This looks good to me. Can you add some unit tests, rebase, and squash? Thanks a lot. |
Sorry but I'm not sure what to test for exactly, any pointers would be great :) |
@@ -143,6 +143,14 @@ public function prepare() | |||
if ($this->headers->has('Transfer-Encoding')) { | |||
$this->headers->remove('Content-Length'); | |||
} | |||
|
|||
|
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.
You should remove one blank line here.
Writing tests should be easy enough: check that the pragma header is set when the right conditions are met. |
@dlsniper I've merged your changes in the 2.1 branch as we don't have enough information in 2.0 to make it work correctly (we don't have access to the Request and so the protocol is always 1.0). Also, I've reverted the changes to the getMaxAge() method as the getExpires() method always returns a DateTime instance. |
@fabpot thanks. Unfortunately my time is a bit limited at the beginning of this week, hence the lack of response from he with regards to the test. Best regards. |
* 2.1: fixed CS fixed CS [Security] fixed path info encoding (closes #6040, closes #5695) [HttpFoundation] added some tests for the previous merge and removed dead code (closes #6037) Improved Cache-Control header when no-cache is sent removed unneeded comment Fix to allow null values in labels array fix date in changelog removed the Travis icon (as this is not stable enough -- many false positive, closes #6186) Revert "merged branch gajdaw/finder_splfileinfo_fpassthu (PR #4751)" (closes #6224) Fixed a typo Fixed: HeaderBag::parseCacheControl() not parsing quoted zero correctly [Form] Fix const inside an anonymous function [Config] Loader::import must return imported data [DoctrineBridge] Fixed caching in DoctrineType when "choices" or "preferred_choices" is passed [Form] Fixed the default value of "format" in DateType to DateType::DEFAULT_FORMAT if "widget" is not "single_text" [HttpFoundation] fixed a small regression Conflicts: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php
I'm getting this error : PHP Fatal error: Uncaught exception 'RuntimeException' with message 'The Expires HTTP header is not parseable (-1). since upgrading from 2.1.4 to 2.1.6. Since it's mentioned a few comments up, i'm curious if this patch is responsible. Should i change something in my http cache code to make it work? |
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: not sure, should be
Fixes the following tickets: #4681
Todo: check if this actually works
License of the code: MIT
Documentation PR: ~
@pulzarraider or @sstok does this work for you guys? I'm not sure how to test it nor do I have IE as I'm on Ubuntu.
Thanks!