Overriding XML/HTML Page Caching

There are times when we don’t have control over pages being cached ( IE Provides the ability of not Caching your pages). The down side of this is, when a request for a page has been made more than once and the data expected is not the same  every time, The browser returns the same data as the first time.

To avoid this, add the following random key as a query string to the URL, this ensures that the URI is unique on every request. So even though caching occurs, the Browser treats each request as a new one.

var url = "status.xml?RandomKey=" + Math.random() * Date.parse(new Date());

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s