Web browser not loading from bfcache always - javascript

I have an e-commerce application that is built on JavaScript and HTML for the front end (uses gulp to bundle). I am facing an issue with it while returning to a page from the back button. On most occasions, the page would simply rerun all the javascript that was initially executed to construct the page. In some rare cases, it behaves as expected which is no JS is executed when the page is hit by pressing the back button on the browser. I confirm that there are no meta headers or response headers that will invalidate the cache. I can see that the rerun is initiated by the browser and not by any of my JS codes. Could someone shed some light on what could cause this to happen?

Related

How to auto-refresh a web page, even if server returned an error?

I have an HTML+JS web page, which uses http-equiv="refresh" to auto-refresh itself every few seconds. However, sometimes the server returns a 502 "bad gateway" error, so the HTML code is not loaded to the client and thus this auto-refresh does not work any more. However, mnanually refresing the page via F5 in the browser does correctly reload the page.
Now I would like to make this page a bit more robust by allowing itself to refresh, even after a 502 error has been returned. So in other words, the client should try to reload the HTML page after X seconds, in any case.
Is there any way to achieve this kind of auto-refreshing, even if the server does return an error instead of the real HTML page?
I found a solution. For the records:
The page content (everything within the <body> tags) has been moved into another page, which is displayed on the main page (wrapper) via an iframe. That wrapper page itself does the reloading via JS.

Website refreshing randomly with an unknown parameter &mn

My website is refreshing randomly by itself with an additional unknown URL parameter ?mn followed by a Hash. Example:
?mn=l4ehjinilk0ids2leotmtyrmttfuq4oqedu.eebubnay47ddfhvd
I really don't know where it comes from. It happened even in Incognito mode.
Website is on Sitecore.
Any ideas?
If the page is loading correctly from the server but then refreshes with additional parameters in your browser, it must be triggered by JavaScript code. It can be caused by your own JavaScript, scripts injected by a third-party snippet, scripts executed by your browser extensions and so on.
Follow the steps below to find what triggers this refresh:
Open Developer Tools in your browser and navigate to the Network tab
Select the Preserve log checkbox
Reload your web page to replicate the issue
Find the request with parameter ?mn= and select it
Go to the Initiator tab, it will show the request call stack or request initiator chain similar to this:
This can help you understand what in your browser triggered the web page refresh.
Thank you.
I finally found out.
It was due to the Zoom application, a Post-attendee URL was set, as soon as a meeting is done, Zoom triggers the default browser and redirects to a website.

Wamp not recognizing a change in my code?

I'm working with Wamp, and i just added a console.log line.
console.log("message);
However, the message isn't being displayed in the console. After a bit of research, i found out that the source code of the page displayed on my browser ISN'T including the console.log line.
It seems like Wamp isn't recognizing the changes in my code all of a sudden.
I tried restarting it but still the same issue. Any ideas ?
This is javascript you are amending. Javascript is cached in the browser, so if you make a javascript change on the server it is sometimes necessary to tell your browser to refresh all its cache's.
You do this by loading the page you want to see and then pressing CTRL+F5 (both together) The browser will reload the page and all its resources, bringing up your amended javascript from the server in the process.

Clearing HTML 5 offline cache programatically

Is it possible to stop and clear the offline cache (HTML 5) programatically?
Explanation:
I've got a working offline web app. That web app is updated frequently (changing the manifest), causing the browser to request the page from the server again. Now under some conditions (e.g. internal errors) the website may send an error page instead of the actual page under the same URL. This is something i can not prevent. But in that case, i want the brower to stop caching, so the error page is not getting cached and thus not being loaded everytime the user tries to access the URL (since the page might work again already)
I am using C# (ASP.NET) and JS for that website.

Browser loads duplicate copies of scripts

If I open my webpage and then look at developer tools on the browsers like chrome/firefox/ie, I see multiple copies of the same view/javascript files loaded. This can potentially screw up how javascript behaves wrt to its state.
Almost everytime, doing page refresh would solve it.
This happens very randomly.
I am not at liberty to post my code, but the set up is nginx/thin/ruby/haml.
What can lead to such behavior? is the problem on the server side or browser side?
Our initial hunch was that may be they are multiple versions of the same doc, but all of them are exact replicas. So I ruled out caching as possible culprit.
More info about the page:
No dynamic loading of scripts - simple script tags
No frames on the page - simple body tag with a form in it
No advertisement scripts on the page
happens on all browsers
intermittent - frequency is like once in 500 page loads

Categories

Resources