Note that there are some explanatory texts on larger screens.

plurals
  1. POContent negotiation ignored when using browser Back button
    primarykey
    data
    text
    <p><strong>Here's the situation:</strong></p> <p>I have a web application which response to a request for a list of resources, lets say:</p> <pre><code>/items </code></pre> <p>This is initially requested directly by the web browser by navigating to that path. The browser uses it's standard "Accept" header which includes "text/html" and my application notices this and returns the HTML content for the item list.</p> <p>Within the returned HTML is some JavaScript (jQuery), which then does an ajax request to retrieve the actual data:</p> <pre><code>/items </code></pre> <p>Only this time, the "Accept" header is explicitly set to "application/json". Again, my application notices this and JSON is correctly returned to the request, the data is inserted into the page, and everything is happy.</p> <p><strong>Here comes the problem</strong>: The user navigates to another page, and later presses the BACK button. They are then prompted to save a file. This turns out to be the <em>JSON</em> data of the item list.</p> <p>So far I've confirmed this to happen in both Google Chrome and Firefox 3.5. </p> <p>There's two possible types of answers here:</p> <ol> <li><p>How can I fix the problem. Is there some magic combination of Cache-Control headers, or other voodoo which cause the browser to do the right thing here?</p></li> <li><p>If you think I am doing something horribly wrong here, how should I go about this? I'm seeking correctness, but also trying not to sacrifice flexibility.</p></li> </ol> <p>If it helps, the application is a JAX-RS web application, using Restlet 2.0m4. I can provide sample request/response headers if it's helpful but I believe the issue is completely reproducible.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload