GET request
The main goal of GET request is to show some data to the user: page, part of the page, control or just data. GET request shouldn’t contain any data changes or any function that leads to changes in the system to be done. Based on that it’s logical to cache GET requests, until page update after another POST request is needed.
IE Caching
While working with with AJAX GET requests in IE it becomes obvious, that results are cached in all cases, except the situation, when development tools are opened.
E.g. when user clicks the button “To Basket”, it’s required to refresh basket summary without page reload. It’s easy to reproduce with JQuery function load:
$ (“[container selector]”). load ("[URL]");
This function will replace the content of container with results of URL GET request. and in IE it always will be the same result.
Resolving the issue
Here described two possibilities to resolve the issue:
- Switch off cache is most logical operation. In case of using query you can use the function.ajax with the parameter cache set to false, or switch off cache for all JQuery requests$.ajaxSetup ({ cache: false });Otherwise add header Cache-control with value no-cache to request.
- Add dummy parameter to any request you don’t want to be cached. This solution looks more like hack and not like a real solution, but, unfor
$(“[container selector]”).load("[URL]", { dummy: Math.random() });
Comments
Post a Comment