Window.open displays the cached version of page

Window.open JavaScript function inherently opens the cached version of the page requested. For the first time the web page will be brought from the server, but for subsequent requests it will display the cached version of the page that was bought first. How to avoid this..?

Window.open shows the cached version of the page ONLY if the URL requested matches the cached page URL. The best option is to change the URL every time you try to use the window.open statement. This can be achieved by two methods:

  1. Append a dummy queryString with Random value
  2. Append a dummy queryString with DateTime stamp

Out of the two the second method is most reliable, since the DateTime stamp will be unique every time you invoke the window.open statement. Example:


var dt = new Date().toString();
var URLToOpen = 'http://server.com/page1.aspx?TimeStamp=' + dt;
window.open('New Page','',URLToOpen);

Your comments are welcome.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s


%d bloggers like this: