0

I have a dynamically updated html page through jquery(ajax) named 'home.html'. After this dynamic update on the page, I go to a next page called 'takeexam.html'. But when I go back to the home page from takeexam, the dynamic updated html is not there and I see only the html which was generated during pageload. But when I check this with mozilla or IE, this dynamic update is available on back button. What is the problem in chrome and how do I solve this ?

dynamic update - I add few html into the DOM, checking from ajax response using jquery

As far as I have noticed the server, Internet explorer and Mozilla makes a request to the server and serves the page on back button, but chrome does not make request to server on back button and so is the problem.

What is the best way to solve this ? How do I make all the browsers make request to server on back button click.? Or is there any better way to do this ?

fyi - Preserve dynamically changed HTML on back button - I have already read this and I am not able to understand this thread

Community
  • 1
  • 1
Yogi
  • 1,561
  • 5
  • 26
  • 45

2 Answers2

1

Without knowing what kind of dynamically updated HTML you are talking about (eg. new components, style changes, etc...) we cannot guide to a particular answer.

I can say that if state is important use hidden text fields, cookies or/and localstorage. And based on localstorage dynamically regenerate the page to it's previous configuration.

user7753083
  • 95
  • 2
  • 9
0

After few hours of learning, the problem is because of the caching in chrome. I have set the HTTP headers Cache-Control: max-age=0, no-cache, no-store, must-revalidate.

This makes the page not to cache and when we are requesting this page again, the browser do not have cache and so it makes request to the server again.

But I still cannot understand how IE and Mozilla makes it work without explicitly setting the HTTP headers.

Yogi
  • 1,561
  • 5
  • 26
  • 45