Invalidate browser cache of back button (bfcache) after posting to an iframe
I have a form which submits to an iFrame (this is a common approach to Ajax image uploads since you can't send multipart forms over ajax) and then uses some javascript to update the parent page with the new image.
I'm wondering what开发者_StackOverflow社区 the best way is to invalidate the browser's cache of the page after the request.
The problem I'm seeing is if the user clicks to the next page and then clicks back, the page won't be current (it's using the out of cache version without the image). But if they reload the page it is correct.
I'm using Jquery btw. It seems to invalidate it if I change the url of the page with javascript like this:
window.location += '?123';
Does this mean I need to somehow keep incrementing the number after any number of requests to the page, or is there an easier way? Thanks!
Calling unload on the window will invalidate the cache:
$(window).unload(function(){});
You can do this in the function which updates with the new image.
精彩评论