I have been recently working on a website for myself, http://retrixsolutions.pw/, and I have a process before which loaded my website and redirected it to another page:
<script type="text/javascript">
document.location = "homepage.html";
</script>
Using this script, it automatically redirected my websites' index.html to homepage.html
I then looked into another website design and decided I liked that one better. I removed the files on my CentOS webserver and then uploaded the new ones. These files do not require me to redirect.
If you go to http://retrixsolutions.pw/ it works, but if you go to http://retrixsolutions.pw/index.html, it redirects to another page even though the script to redirect is completely removed.
I have restarted my webserver, shut it down and then re-uploaded the files but still the index.html file relocates to homepage.html.
Thanks for your help.
Adding on to what JBDouble05 said, another easy way to clear your cache is to hold Shift while clicking the refresh button.
What you'd need to do is make sure your browser is not caching the files. Caching is essentially the browser saving time and effort, and it saves a local copy of the file to its storage, which means that if you boot up that page, it will load the saved file, even if the file online changes. To clear cache, you can refresh the page, hard refresh and clear cache, or use an incognito or private browser (such as Epic)
Related
I use Hostinger for hosting. Although I uploaded my files successfully, Chrome won't show the changes, while windows Explore does. It seems that the browser remembers the old version of the page and doesn't download the new files. It's the same on my friend's computer and phone, whom I showed the page before the update.
The page is pure HTML, CSS, and a bit of JavaScript. How can tell my browser it's a new version of a page? Without manually clearing the browser history etc.
www.michalrucinski.com
https://github.com/michalrutz/porto
You could rename index.html to index.htm so the old file would longer exist and the browser would be forced to search for an alternative file.
Or you can set up cache control in the HTTP headers, e. g. using .htaccess if your hosting plan supports it.
I'm looking for a proper way to inform users about an updated website version.
Whenever I upload new production .js files some parts of the website still works properly without refreshing the browser, but most doesn't and users might never figure out to just refresh the browser.
How can I give an automatic notice for users to refresh the browser, whenever new .js files are uploaded?
I'm using Vue and Laravel-mix.
A cache buster is required and can be automated with eg. gulp-rev: the concept is to rename resource files at each build, so that they won't be retrieved from cache when the user opens your app.
But it's not sufficient if the browser tab is open and the upgrade is done while the user is using the app. In this case, perhaps you want to display a modal message to refresh the page, or automatically refresh to load the new version.
For that, you should store the version number (or git commit hash) somewhere in your SPA scope when the app is first opened, and periodically check the current backend version with a webservice call. If you detect a version change, you'll display the message (and prevent the user from using its old version).
I wrote a javascript code inside an codeigniter page but when i refresh the page the previous code is still there. I tried opening it in incognito and it was updated and working. Why is that?
Browser is caching css and js file.
So sometimes when you refresh it load files from previously stored cache.
Reload all fresh file use - ctrl+f5 or ctrl+shift+f5
Read more ---> Wikipedia:Bypass_your_cache
In Javascript, what is the preferred way to validate if a GWT *.nocache.js file has loaded properly?
Background
My GWT application loads an *.nocache.js file within a simple shell .html page.
If a user visits the page with a stale auth cookie, the .html file loads perfectly from browser cache, but the *.nocache.js file fails to load, because the user needs a fresh auth token.
Since the .js file fails to load, it fails silently. The user sees a blank .html page with no indication that they need to refresh the page.
(note the particular failure here is that the .js file does not load due to wrong mime type. The auth layer handles stale auth cookies by redirecting to the login page. This page is a text/html document so the browser rejects loading it in a tag. Assume for this question that I cannot change this behavior in the application :)
What's the best way to detect this circumstance and, for example, force a refresh of the page.
Note a hard refresh will force a fetch of the .html page from the server, which will be redirect to the login.
One approach would be to tell the browser to not cache the .html file, but I'd prefer another solution that lets the .html file be cached.
Given that you cannot change things in your application, I will answer just to your question.
You need some javascript in your page.html in order to check whether the gwt script has been loaded after a fixed time:
<head>
<script>
setTimeout(function() {
if (!document.getElementById("my_module_name")) {
window.location.reload();
}
}, 4000)
</script>
<script language="javascript" src="my_module_name.nocache.js"></script>
</head>
In the case you use an iframe based linker (standard, xsiframe), the .nocache.js creates an iframe to load the appropriate permutation, and gives it the name of the module, so checking for the presence of that element after a while is enough to know whether the app was loaded.
You could also check for the presence of especial properties which gwt sets to the window like window.__gwt_activeModules
Typically, a GWT app loads first, then you do authentication. You can use a split point, if you want, to load only the login page. Then, after the authentication is confirmed, you load the other parts of your app.
I have never seen a scenario where authentication is done before a page loads. Maybe you can explain why you did it this way.
As for your question, you need a JavaScript to detect if another JavaScript was successfully loaded, but this solution adds an unnecessary level of complexity.
i was wondering - when using jQuery (or any other javascript include) in my web,
does the browser cache it after the first download for all all pages (i assume yes) or will it download it every time?
2nd, when the user quits the browser and starts it again (for loading my website), will the jquery js file still be cached or will it completely download again?
thx
This depends on the browser and on how your server is set up. Have a look at the headers sent by the server along with the file (you can use a tool like Firebug to look at the headers). A good idea is to use the jQuery file hosted by google, since many other sites (including stackoverflow) use the same file. Then the browser can cache that file and never download it from your server. This page has a list of files hosted by google, and this page explains how to properly set your server up to (tell your browser to) cache files.
1: Yes, the browser caches all jscript/css includes
2: If the user does not clear his/her cache. Yes it will still be in the cache of the browser, even after closing and reopening it.
If your webserver serves jquery.js using a proper expires header, then yes, the browser will cache it.
http://developer.yahoo.com/performance/rules.html#expires
Yes the scripts will get cached between page views, along with the CSS files and images.
Yes as well, in general. The cache is normally maintained between browser restarts.
It will typically not be downloaded again, but unless your server explicitly tells the browser to cache it for a while, then it will send a request on each page load asking "was jquery.js updated?" which is almost as slow as just downloading it again.
You can test how it works on your site with Google's Page Speed or Yahoo's YSlow.