0

I just added a math.random() object to my document.location statement to generate a unique url and prevent the page from being cached.

document.location="http://www.my/project/site/" +Math.random()+"";

The code produces the desired unique url, but I don't know how to test to verify that the page is not being cached. Is there a javascript method that can detect whether or not a page is a cached page?

kjarsenal
  • 934
  • 1
  • 12
  • 35
  • Possible duplicate of [How can I use JavaScript to detect if I am on a cached page](http://stackoverflow.com/q/260043/851811) – Xavi López Oct 04 '11 at 16:09
  • Other than pages retrieved via ajax, I don't think there's anything in JS that lets you get the http status code for the current page. Would be handy... – Marc B Oct 04 '11 at 16:11
  • if duplicate, apologies. I looked but didn't see the other page. – kjarsenal Oct 04 '11 at 16:15

2 Answers2

0

Hi there's no way in javascript that I know of, but firebug and developer tools in chrome will tell you whether each resource has been cached or not

George
  • 515
  • 2
  • 6
0

Use Firebug or Developer Tools (w/e your particular browser calls them).

Most of them have a "Network" tab that shows you information about all of the files being used on the page, including, whether or not they are loaded from cache.

simshaun
  • 21,263
  • 1
  • 57
  • 73