Shiplu
Shiplu

Reputation: 516

How to detect that the page was just restored from the page cache (eg. From the Back button) in jquery?

There is a situation that when a user came back to a page by clicking back button then I need to send an ajax request. Is there any solution?

Thanks

Upvotes: 1

Views: 236

Answers (1)

Naman Upadhyay
Naman Upadhyay

Reputation: 537

The following article should answer your question:

Detecting when a page is loaded from the browser cache.

The concept of the above article is that at every request you set the cookie from the server side and check the cookie using JavaScript (or jQuery). if the cookie matches that of the previously requested page, then it is a cached page. If it doesn't, it is a fresh page.

Hope that helps.

Upvotes: 0

Related Questions