Bug 114517 - Webkit reuses cache with different headers
Summary: Webkit reuses cache with different headers
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: History (show other bugs)
Version: 525.x (Safari 3.2)
Hardware: PC Windows 7
: P2 Normal
Assignee: Nobody
URL: http://br.kekanto.com/search?&c=26985...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-12 10:41 PDT by Omar Ajoue
Modified: 2013-04-16 10:21 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Omar Ajoue 2013-04-12 10:41:44 PDT
In order to reproduce this bug you should follow the following steps:

1) browse the following url: http://br.kekanto.com/search?&c=269853&m=c&lat=-23.548547000&lng=-46.638272000&q=pizza&near=S%C3%A3o+Paulo
It shows a list of places selling pizza in Sao Paulo.

2) Click either the star rating filter or price range (star and dolar signs respectively; NOTE: these are anchor tags <a>).
The pages reloads using AJAX and the new results are shown. I use pushState to create a new URL entry.

3) Navigate away from the page (like clicking a place name)

4) Press the back button

The expected result should be the same listing as before, but the actual result is a JSON.

Problem is: The URL pushed in the pushState is the same as Web Service used to populate the page. The browser considers it has a copy of the page and serves it, but that is a JSON. The same URL, if requested with the X-Requested-With: XMLHTTPRequest brings a JSON instead.

NOTE:
If you click a checkbox in the page it triggers the EXACT same reload function, but this does not cause the problem. Only happens only when browsing using anchor tags that change the underlying form and trigger a submit via AJAX.
Comment 1 Brady Eidson 2013-04-16 09:27:44 PDT
If I understand this report correctly, you're saying that you wished WebKit would not look up a request to this URL in its cache if the value of the X-Requested-With header differs?

If so, try making your server reply to requests for this URL respond with "Vary: X-Requested-With".
Comment 2 Omar Ajoue 2013-04-16 10:21:30 PDT
Thanks a lot Brady for your answer, this really solved the problem - I tried adding the response header Content-type: application/json but it still kept showing the JSON file instead of a page.

Now with the Vary header everything works as expected.