-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Sending Vary header for AJAX requests. #1133
Comments
👍 |
The problem was connected with reverting closed tab. I can imagine, that in this use-case it ignore expire header. @vojtech-dobes what was the reason for you workaroung? was it a problem only in Fx? |
It also happened when navigating Back, eg. I click on link to another |
The question is where send Vary header. In Presenter::sendPayload()? |
I guess that would be ideal. It seems to me fine to leave using of that header to developer's good judgement if he doesn't use payload. |
I would say more like the json response? It feels more right in there. |
Vary header should be send everytime, when the url serving different contents because of some header. This has nothing to do with sendJson (or json response), action could return json everytime, no need to send vary header. In general, this is about nette approach with snippets & ajax, so it should be send everytime we render template with snippets. |
Nette should send Vary always as per RFC
Pulling snippet information from rendered template or detection if some code path is using ajax would require hacking probably with some ob_start(). What about adding config nette.response.vary = off (default: X-Requested-With, Cookie, Accept-Encoding) or something like that that would send it always. Or maybe adding configurable headers using nette.response.headers.X-Powered-By: off (default: Nette Framework) would solve this as a feature since some fixed headers are generated by NetteExtension anyway and there is no way to turn them off. |
added nette.http.headers f59f3b1 |
Well, the added api is nice, but seem to be quite unrelated to this bug, doesn't it? |
This can not be solved automatically because when we render page we don't know if it contains a snippet. It may be inside the component. What about send Vary header always by UI\Presenter?. Unwanted side effect is minimal and it solves the problem. public function run(Application\Request $request)
{
...
if (!$this->httpResponse->isSent()) {
$this->httpResponse->addHeader('Vary', 'X-Requested-With');
} |
Yes, agreed! |
Perfect, thank you! |
We must add Vary header, which tells the browser that the cache should depend on XHttpRequestWith header.
vojtech-dobes/nette.ajax.js@07f03cc
Related bug in Firefox (months ago fixed): https://bugzilla.mozilla.org/show_bug.cgi?id=633743
The text was updated successfully, but these errors were encountered: