Umair Umair - 4 months ago 35
Javascript Question

Make window.location.href load page from Server instead from browser cache

I am making a redirect using

window.location.href
to Listing view after an Item is added to DB after successful CREATE operation.

But what it does, it simply fetches old page (not showing the newly added item) that was previously in borwser's cache.

I want it to fetch every think from server, just like we use
true
parameter in
document.location.reload(true)
to load a fresh copy of page from server.

Answer

You can use this:

window.location.href = "http://www.mywebsite.com/products?t="+ (new Date().getTime());

Or:

window.location.href = "http://www.mywebsite.com/products?t="+ Math.random();
Comments