I’ve found many answers on Stack Overflow about how to refresh an iframe with JavaScript.
For example:
They work fine. However, if the page in the iframe has changed recently, the refresh will not show this change. Is there any way I can force a hard refresh on the designated iframe so that the new version is shown?
If the
iframeis same-origin, you can force a full page reload using↪ View an example at jsFiddle
↪ More information at the Mozilla Developer wiki
If you have control over the HTTP headers sent for the page in the
iframe, you can also instruct the browser not to cache it in the first place.Furthermore, most web pages completely ignore parameters in the query string for which they have no handling code, so you could add a random value or a timestamp to the query string to make sure the browser sees it as a “new” page and does not use the cached copy:
Use
new Date().getTime()instead ofDate.now()if support for older browsers is important.