Cleared cache and Chrome won't stop using old CSS - html

I've been developing a website locally and have uploaded the website a couple of times to my server on Siteground for testing. With this newest upload I cannot for the life of me get chrome to stop using my old css file.
I have completely cleared the cache many, many times. I have removed the CSS files from my server completely and done the same, so the site should be rendering free of any and all CSS. I have double-checked via cPanel file management to make sure there are no CSS files.
It renders as it should (with no CSS) in every other browser but still not in Chrome! I imagine this is a very simple problem with a simple answer and I am just not seeing it.
Here's the website.
What it looks like in Chrome:
What it looks like in every other browser:

Try CTRL + SHIFT + R instead (shortcut key for Hard Reload in Chrome).
You can also try add ?ver=anynumber at the end of your linked css to force browsers to reload it:
<link rel="stylesheet" href="assets/css/styles.css?ver=100">

If you're using Windows then try Ctrl+F5 or Shift+F5 keys.
On Mac OS X try holding both the ⌘ Cmd and ⇧ Shift keys and press the R key.

When you click Ctrl-Shift-Del in Chrome it opens the "Clear browsing data" -page. You can and should check the check-box "Browsing history".
However note that above that you have the setting for "Time Range". Choose "All time". That seems to NOT be the default.
If you don't choose "All time" then perhaps counter-intuitively older resources stay in the cache whereas only ones cached during last hour or so may be removed.

Related

Are both Shift+F5 and Ctrl+F5 valid for cache bypassing in Google Chrome?

I have been always using Ctrl+F5 on Chrome when I needed to ignore cache and load a new content. Today, I found out that my colleague is using Shift+F5 for the same and apparently, with the same result. My best guess was that the first one just bypasses the cache and the second one is clearing them completely. But I'm not sure, because I didn't find any article comparing these two specifically (apart from Ctrl+F5 and F5, or Shift+F5 and Ctrl+R...).
Only thing I found is this forum post, where it says these combinations don't reload the page anymore. So, how come I use it with the most recent version of Chrome and apparently, everything works as expected?
So I went to the official list of Chrome shortcuts, where there is not a single trace of Ctrl+F5 that I still use to this day. And I'm updating css files without a version tag couple times a day, so I can tell it works.
Can you help us sort this thing out?
There is absolutely no difference.
Ctrl+Shift+R / Shift+F5 / Ctrl+F5 Does exactly the same in Chrome - reload the page ignoring cache (images, scripts, css files)
I am speculating Shift+F5 is Chrome way to reload, while Ctrl+Shift+R/Ctrl+F5 is added for compatibility with other browsers.
For putting an example in Firefox Shift+F5 open Performance tab in developer tools, so for those who use both browsers is more comfortable to use Ctrl+F5 combination.
Your observation is correct!
Follow the following steps to verify your observation:
Open menu>More tools> Developer tools or Ctrl + Shift + I.
Navigate to Network Tab, and observe requests and data transfer figures on the bottom of the page.
Open the webpage of your choice, I used apple.com (as it shows you the considerable difference in the figures)
Now try F5/Ctrl + R, Ctrl + F5/Ctrl + Shift + R/Shift + F5.
Note: Ctrl + F5 is a shortcut specified in the official document of Firefox.
Firebox Shortcut Page

CSS style is not applied to website after saving (running on XAMPP localhost)

I recently started with PHP and so I also started using XAMPP, for the last two days when i change code in the CSS file at first it does not update this on the website. like last night I changed something and only this morning when I started it up again it was applied. XAMPP is online with ProFTPD, Apache and MySQL running, the Network is also online. Why is this? It has only been like this last 2 days before that it worked fine.
Tried to restart everything and changing the file path.
this issue is not related to using Xampp, i think the browser you use is caching the css file which means you won't be able to get the updated CSS each time your refresh your page.
if you are using Google Chrome you will need to go to the browser settings and disabled the cache mode in the development version, and to do this use the following steps:
1: Inspect this page or any page (F12 if you are using Windows).
2: press F1 and the settings will be opened to you.
3: at the Network section at the right side under Elements check (Disable Cache Whilte DevTools is open)
4: close everything and open it again and you will be able to get the updated CSS style each time you update this file
there's also another solution, is to change the style URL version each time your update the style file like this => siteURL/style.css?ver=1.1.161017 (Adding Ver=number) will force the browser to update the cached CSS file
hope this help
You can use a keyboard shortcut to open an Incognito window:
Windows, Linux, or Chrome OS: Press Ctrl + Shift + n.
Mac: Press ⌘ + Shift + n.
This could be a caching issue.
Having Chrome as active window try to press Ctrl+R or Ctrl+F5 (forcing cache purge) on your keyboard.
It was indeed a caching issue.
Fix: Inspect this page or any page (F12 if you are using Windows) 2: press F1 and the settings will be opened to you. 3: at the Network section at the right side under Elements check (Disable Cache While DevTools is open) 4: close everything and open it again and you will be able to get the updated CSS style each time you update this file.
Thanks to everyone who helped really appreciate it!

Removing "Default" Favicon

I have a localhost instance I run on a given port, and when developing a site for another client, my previous clients favicon still shows in the tab even though the client has no favicon. How do I remove my previous client's favicon from the browser/server? It does it Safari, Chrome (OS X), and Firefox. I've tried the force refresh (Mac equivalent of Ctrl + F5) to no avail. Any help would be appreciated.
Thanks.
Clear the browser's cache: Ctrl-Shift-Delete (Cmd-Shift-Delete), select what to clear, and for what period of time. Because the new website has the same host as the old one, browser may still think you're on the previous site and display your cached icon.
Or just add a favicon to the new site.
You can force a browser to download new instances of similarly named files by adding a version to them in the form of a query parameter, and updating the version as needed throughout development.
<link rel="icon" href="localhost:4200/favicon.ico?version=2" />
Other than that, closing the tab, and in some cases restarting the browser works if force refreshing the cache didn't.
These are typically stored in with the temp internet files on your server. Clearing the history, cookies, and meta-data should take care of this.

CSS is not updating in browser instanly

I am having this problem for long time. Whenever I update my existing stylesheet it not take effect in browser instantly. If I view page source and click on my stylesheet, ex:<link rel="stylesheet" href="assets/stylesheets/theme-custom.css"> recently added codes are not shown. It updates after few hours. This happens both in Firefox & Chrome.
Why this happening? And how can I get rid of it?
Due to performance reasons browser cache loaded css files. So if you update your css you have to clear your cache. You can also reload the page with clearing it by pressing CTRL + R.
At the following linked page you can find approaches how to deliver your css and force browsers to get the current version (like adding timestamps or anything else as parameter):
https://css-tricks.com/can-we-prevent-css-caching/
EDIT:
You can also just disable the caching completely in the settings or developer tools of your browser.

How can I force a hard reload in Chrome for Android

In Chrome for desktop I have options in the dev tools to disable cache completely when dev tools are opened and I have the options to manually do a hard reload when long clicking on the reload button (with dev tools open).
Is there any such technique for Chrome for Android? I didn't find any setting.
What can I do when I want to force the browser to download some javascript or css file instead of using a cached one when developing?
I'm using window.location.reload(true) according to MDN (and this similar question) it forces page to reload from server.
You can execute this code in the browser by typing javascript:location.reload(true) in the address bar.
Viewing the page in incognito mode will disable the cache. It was the only way I could force a refresh on a stylesheet without manually clearing the cache through the settings.
Also an option:
Menu
Settings
Privacy
Clear Browsing Data
Check "Cache" and press "CLEAR"
and then reload the page.
You can use the Request Desktop Site option from the app menu (to the right of the address bar) which will force the page to reload.
Simply tap it, wait for the refresh, then deselect it.
Mentioning this because you mentioned "when developing".
You can control the mobile device via your Chrome Desktop Browser.
Visit chrome://inspect/#devices on your desktop. And Inspect the device that's connected to your desktop. Agree when asked for permission.
You should now see a full fledged Devtool window for the current page on mobile device.
Now, Use the hard reload shortcut (Cmd+Shift+R) on desktop to do hard reload on mobile device!
How to reset all data for a given URL / Website on Chrome Mobile for android:
1 - Open the Chrome menu, and tap on the "i (info)" icon
2 - tap "Site settings"
3 - Tap the trashcan icon
That's it, even the most deeply ensconsed service worker for that URL will now die.
Don't forget to make sure that the "Reduce data usage" setting is turned OFF, as it seems to download cached data (from Google servers?) even though your local cache is flushed.
I know this is an old question, but I found that the accepted answer didn't work for me.
An alternate solution would be to append the url with a new url parameter
such as website.com?a=1, website.com?a=2, etc.
If you have parameters already, of course, you would use an ampersand
i.e. website.com?q=test&a=1
As of 2018, from google help center (tested on Chrome 63) :
tap on the three dots menu ;
choose History > Clear browsing data ;
if needed, choose the time period (above the checklist) ;
uncheck all items but Cached images and files ;
proceed with Clear data and confirm.
As mentioned in another answer, incognito tabs are also of great use for development.
I found a solution that works, but it's ugly.
Connect the Android device to your PC with a USB cable and open Chrome on your desktop.
Right-click anywhere on a page and select "Inspect".
Click the three-dot menu and select "Remote devices" under the "More tools" menu:
In the panel that opens, select your device and then the "Inspect" button next to the name of the tab on your phone that needs to be refreshed:
In the window that opens, click the "Network" tab and check the "Disable cache" checkbox:
Reload the page on your phone or using the reload button in the DevTools window.
Note: if your phone doesn't appear in the device list:
make sure the USB connection is using File Transfer mode and isn't simply charging
try restarting ADB or run adb devices to see if the device is being detected
The only reliable way I've found that doesn't require plugging the phone in to a PC is as follows:
1. Force stop the Chrome app.
This must be done first, and you cannot re-open Chrome until you finish these steps. There are several ways to force stop. Most home launchers will let you get to "App info" by holding down your finger on the chrome icon and selecting an "i" icon. Alternately, you may be able to go to Android settings and simply search for "Chrome".
Once in "App info", select "Force stop" as shown below:
2. Clear Chrome's cache
Select "Storage" from the same screen:
Finally, select "Clear cache".
When you return to the Chrome app, the page should reload itself and serve a non-cached version.
Additionally, I found a site that makes it easy to test if you've cleared your cache: https://refreshyourcache.com/en/cache-test/
I am in no way affiliated with it. Note that the method to clear the cache mentioned on that site is in fact outdated and no longer valid.
Keyboard shortcuts such as Ctrl+Shift+R work on Android too, you just need a keyboard capable of sending these keys. I used Hacker's Keyboard
to send Ctrl+Shift+R, which did a hard reload on my phone.
Recent versions of Chrome cache very aggressively. Even cache-busting techniques such as "http://url?updated=datecode" stopped working. You must clear the cache or launch an incognito window every time (and make sure data-saver is off).
Remote Debugging allows you to use the desktop dev-tools:
https://developers.google.com/chrome-developer-tools/docs/remote-debugging
If its just the matter of included files, just add version after the path (?v=12345678)
<link rel="stylesheet" type="text/css" href="style.css?v=12345678" />
Whoever loads the page again will see changes.
Most of the answers were not working for me.
Here is a super simple working on my Galaxy S8 in august 2020:
Add "view-source:" just before your http:.... address, navigate trough there to the changed file if different than the html or index.
You will see the unchanged file. Refresh.
Done.
EDIT: This method has been deprecated in Google Chrome and will no longer work.
ORIGINAL ANSWER:
I was able to clear the cache (including subsequent xhr) using chrome://net-internals
Then click the little arrow in the top right
Select "clear cache" from that menu.
Here is another simple solution that may work when others fail:
Today, a fairly simple developer-side solution worked for me when the caching problem was a cached CSS file. In short: Create a temporary html file copy and browse to it to update the CSS cache.
This trick can refresh the CSS file, at least in Android's blue-globe-iconed default browser (but quite likely its twin, the official Chrome browser, too, and whatever other browsers we encounter on "smart"phones with their trend of aggressive caching).
Details:
At first I tried some of the fairly simple solutions shared here, but without success (for example clearing the recent history of the specific site, but not months and months of it). My latest CSS would however not be applied apon refresh. And that even though I had already employed the version-number-trick in the CSS file-call in the head section of the html which had helped me avoid these pesky aggressive cachings in the past. (example: link rel="stylesheet" href="style.css?v=001" where you upgrade this pseudo-version number every time you make a change to a CSS file, e.g. 001, 002, 003, 004... (should be done in every html file of the site))
This time (August 2019) the CSS file version number update no longer sufficed, nor did some of the simpler measures mentioned here work for me, or I couldn't even find access to some of them (on a borrowed android phone).
In the end I tried something relatively simple that finally solved the problem:
I made a copy of the site's index.html file giving it a different name (indexcopy.html), uploaded it, browsed to it on the Android device, then browsed back to the original page, refreshed it (with the refresh button left of the address bar), and voilà: This time the refresh of index.html finally worked.
Explanation: The latest CSS file version was now finally applied on Android when refreshing the html page in question because the cached copy of the CSS file had now been updated when the CSS file was called from a differently named temporary html page that did not exist anywhere in the browser history and that I could delete again afterwards. The aggressive caching apparently ignored the CSS URL and went instead by the HTML URL, even though it was the CSS file that needed to be updated in the cache.
Adding a parameter to url fool browser to load a new page. I wrote a fuction for that purpose:
function forceReload(){
function setUrlParams(url, key, value) {
url = url.split('?');
usp = new URLSearchParams(url[1]);
usp.set(key, value);
url[1] = usp.toString();
return url.join('?');
}
window.location.href =setUrlParams(window.location.href,'_t',Date.now());
}
And you just need to call it:
forceReload();
I've struggled with this for a CSS file that wouldn't refresh. But you can type the name of the CSS file itself into the address bar and refresh that. After that it's fine. Chrome on Android 8. Obviously that would be tiresome if you had more than a couple of files involved.
If that's an option, you can visit the (i.e. JavaScript) resource directly, reload a bunch of times, and that also triggers a hard reload for that resource. Then you can reload the actual page again.
Launch the Chrome Android app
Tap on the menu for more options.
Select Settings from the list of options.
Scroll down and tap on the Site Settings tab.
Within the Site Settings open the Data Stored tab.
Tap on the Site URL that you want to delete storage.
Hit on the Clear & reset command button.
refresh the website page.
there are few methods to force reload chrome on mobile device:
clear history (look above)
use remote debugging (look above)
request desktop site
disable "Lite mode"
open URL for .JS or .CSS then do normal reload.
In chrome,simply tick "Desktop site" and then remove tick!!