Question

I have an HTML page which when loaded triggers some AJAX calls, results of those calls are either stored in hidden text-area (mainly for JSON output) or into div (for ajax calls returning HTML content).

What I'm trying to do is to avoid having to make those AJAX calls when leaving the page and then using the back button. This actually works for the AJAX output stored in text-area, where in fact after a back data is still stored in those fields without having to re-call those AJAX requests, but for what is directly outputted in a DIV it is not the case, meaning that the request will have to be re-called.

What advice can you give me for managing this? Thanks

Was it helpful?

Solution

This actually works for the AJAX output stored in text-area, where in fact after a back data is still stored in those fields without having to re-call those AJAX requests, but for what is directly outputted in a DIV it is not the case, meaning that the request will have to be re-called.

Browsers "cache" content of form fields under certain conditions; but they won't "cache" dynamically added HTML elements.

What advice can you give me for managing this?

With an appropriate caching policy making the AJAX request a second time should not be too costly - the browser will figure that he already has this resource in his cache, and it should be available almost immediately, without any delays caused by an extra HTTP request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top