Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML link that forces refresh?

Is there a way to construct a link to a URL that forces the browser to ignore any cache it might have for that URL?

We have some websites that have recently changed after literally years of static content. Users click shortcuts, favorites, or type URL's to these sites and get old, cached content. I would like to have a page with a link that goes to the same URL but forces the browser to get the fresh content.

is that possible? Cross-browser?

like image 382
n8wrl Avatar asked Aug 13 '09 17:08

n8wrl


People also ask

How do I force a page to reload in HTML?

The trick to reloading the page is to force the browser to not look into the cache, but rather to again make a connection to the Web and bring up the document from the server. Most people know it can be done by hand by holding the shift key and clicking the “Refresh” (on IE) or “Reload” (on Navigator) buttons.

How do I refresh a website link?

Force-refresh your web page.Windows — Press Ctrl + F5 . If that doesn't work, hold down Ctrl and click the "Refresh" icon. Mac — Press ⌘ Command + ⇧ Shift + R . In Safari, you can also hold ⇧ Shift and click the "Refresh" icon.

How do I refresh a page using anchor tag?

After you set the specified URL into location, issue window. location. reload(true) . This will force browser to reload the page.

How do you make a href not refresh?

If you put # inside the href like <a href="#"></a> then the link will not refresh or reload when clicked.


1 Answers

  1. Change all the links to the page with a nonsense query parameter: products.html?happy=days
  2. Change all the resources on the page to use another nonsense query parameter: style.css?the=fonz

You can do it in a systematic way using dates or timestamps or version numbers, or haphazardly using sitcoms, muppets, mountain ranges, and small mammals.

like image 54
Tom Ritter Avatar answered Sep 21 '22 09:09

Tom Ritter