How To Avoid Cashing AJAX ?                 Ramzi Sh. Alqrainy                 qcs_2008@yahoo.com   1
How to clear the cache ?You cant actually clear the cache as its controlled bythe browser, but you can ask how to avoid ca...
What is the problem ?   AJAX application tends to frequently ask the server    for the same URL (a stock quote, applicati...
What is the solution ? Imagine yourself you can not change  HTML file. So, How to avoid caching  AJAX? If you want bypas...
What happened ?   Adding a pseudo-random parameter to the URL    the AJAX application is requesting. Doing so will    foo...
Thank You      Ramzi Sh. Alqrainy      qcs_2008@yahoo.com   6
Upcoming SlideShare
Loading in …5
×

How to prevent the cache problem in AJAX

4,266 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
4,266
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

How to prevent the cache problem in AJAX

  1. 1. How To Avoid Cashing AJAX ? Ramzi Sh. Alqrainy qcs_2008@yahoo.com 1
  2. 2. How to clear the cache ?You cant actually clear the cache as its controlled bythe browser, but you can ask how to avoid cachingAJAX ??Ooooops, What is this problem ? Ramzi Sh. Alqrainy qcs_2008@yahoo.com 2
  3. 3. What is the problem ? AJAX application tends to frequently ask the server for the same URL (a stock quote, application status and so forth). The AJAX application expect a response form the server while, in fact, after the first request the browser returns the cached page and the AJAX application does not work as expected.So, What is the solution ? Ramzi Sh. Alqrainy qcs_2008@yahoo.com 3
  4. 4. What is the solution ? Imagine yourself you can not change HTML file. So, How to avoid caching AJAX? If you want bypass the cache you can add some random argument to the url:What Happened ? Ramzi Sh. Alqrainy qcs_2008@yahoo.com 4
  5. 5. What happened ? Adding a pseudo-random parameter to the URL the AJAX application is requesting. Doing so will fool the browser to think this is a new page that has not yet been cached. The Date().getTime(); returns a new value every millisecond (or so), the browser thinks this is a new page that has not been cached and requests the URL form the server. Ramzi Sh. Alqrainy qcs_2008@yahoo.com 5
  6. 6. Thank You Ramzi Sh. Alqrainy qcs_2008@yahoo.com 6

×