I have a page that can be accessed via URL / products. When I visit it in the browser, it responds with a full page in the layout. The following is a simplified example of request headers and response bodies:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 <layout> <products /> </layout>
When the user searches for javascript update results via AJAX. The results are displayed without a layout, since it takes time to render, and I don't need it:
Accept: */*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript X-Requested-With: XMLHttpRequest <products />
So, this worked fine until I added Cache-Control: private, max-age=3600
caching Cache-Control: private, max-age=3600
. Initially, I would add that the title is Vary: X-Requested-With
, and the browser will highlight two answers. However, when I receive / products through AJAX and then visit / products in the browser, it displays a partial AJAX response.
Is there an easy way to solve this problem?
PS I use Ruby on Rails and jQuery, if that matters.
source share