How can I force a hard reload in Chrome for Android
Asked Answered
B

25

280

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?

Boric answered 2/9, 2013 at 10:39 Comment(4)
This is a duplicate of How to refresh a web page in Chrome (Ctrl+F5 analogue) on a device without menu button? on Android.SE.Sapotaceous
Just returned to extend (what had been) a stable web-app, and discovered that this was happening. The latest state data is stored in a .js file with a cache-buster url suffix. This no longer works, in Chrome on Windows, ChromeOS or Android.Nonie
it seems like a simple refresh (clicking the circle w arrow) detects any changes these days. no tricks. ...let me know if I'm wrong.Incoordination
You seem to be wrong, two years later. My experimental website is cached on refresh.Phocis
L
193

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.

Label answered 3/9, 2013 at 11:57 Comment(19)
Are you referring to the desktop browser? There is no js console in Chrome for Android as far as i knowBoric
Simply type it to the address bar prefixing the code with javascript:.Label
Actually, you should be able to avoid window. part. javascript:location.reload(true) should do the trick.Label
To make this easier you can add that javascript line as a bookmark so you don't have to type it in every time.Faustofaustus
It doesn't work with Android :-( Not better via privacy settings > clear cache.Unintentional
javascript:location.reload(true) worked for me on Android 7.0 in Chrome v55Fenugreek
didn't work for me on chrome v55.0.2883.91/android5.1.1Wolffish
It doesn't work on mine, v56.0.2924.87 on Android 7.1.1. Why can you just hit refresh and have the browser re-download like it used to work? Such an annoyance when trying to develop.Smithers
Since everyone keeps saying it didn't work: It worked fine for me on Chrome 58 on Android 6.Retrospection
Works just fine on Chrome 58 on Android 6.0.1 (Nexus 5)Cave
I open up an Incognito windowSadomasochism
For testing purpose don't forget to disable the server side caching headers. Maybe overwrite or disable .htaccess caching headersPeyter
And how do you do this from the Android Chrome browser?Columbary
On my phone, the true flag is not honored, ergo that is just the equivalent of tapping the reload icon.Paquito
The Parameter doesn't do anything in Chrome, and the default behavior was changed a while ago: bugs.chromium.org/p/chromium/issues/detail?id=670237Priority
for me don't work on chrome 190801.002.only soft refreshed not hard.Dinesh
Can I build this "window.location.reload(true)" into my web app code? How to go about detecting there is a new version of the site and running "window.location.reload(true)" ? Thanks. Web is installed as shortcut onto desktop (android or windows).Convoluted
Incognito works fine, but is a bit of a nuisance if you have a password protection and/or cookie notice popup to deal with every time. There should just be a "hold to select Hard Reload" feature on the reload button.Sugden
MDN: Pass true to force a reload bypassing cache [...] Only supported in Firefox.Lenzi
F
183

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.

Faustofaustus answered 14/7, 2015 at 23:53 Comment(10)
@Wolffish Neither for me.Angelicangelica
Yes, this one is working for me on Android 6.0.1 with Chrome 59.Avoirdupois
This works better than the accepted answer, at least on on Android 7.1.2 and Chrome 61. The caching is really aggressive somehow. Even emptying cached files for that domain did not work for me.Adjoining
I use it more often, if it isn't working for you probably the cache is on the server and not the browser.Sadomasochism
Worked for me on Android 6.0, but only within that Incognito session. Going back to the non-incognito will still download the old cached(?) version of the page.Put
Juha: I had the same result: works on incognito, doesn't do jack for the normal version.Ladle
It will clear cache in incognito mode only the first time. After that the same issue appearsVirginia
Only for that Chrome window. Go back to the URL in a normal session, reload, old cache content again. So it does not empty the cache, it just doesn't read it temporarilyPaquito
incognito mode is not a way how to test PWA - installable apps, manifest file issues,... This functionality is disabled in incognito so the app install banner won't pop up, etc.Following
Thank you, forgot all about using this. Perfect, not back to mobile web design testing.Beige
V
95

Also an option:

  1. Menu
  2. Settings
  3. Privacy
  4. Clear Browsing Data
  5. Check "Cache" and press "CLEAR"

and then reload the page.

Vicky answered 29/8, 2014 at 17:50 Comment(9)
Now its changed to Clear Browsing Data, where you can check clear cache using check box.Human
No, and then, KILL Chrome, relaunch Chrome, then reload the page. Yeah, it just got worse.Minestrone
Update: Even killing Chrome doesn't work anymore. I have NO idea what the hell the option "Cached images and files" is clearing.. it still holds on to the cached CSS file. This is getting more ridiculous!Minestrone
Update: See heidgert's answer. Clearing cache might still load "cached" result from Google's servers if "Data Saver" is turned on in Chrome settings.Minestrone
This will clear the cache from ALL sites, not just the inspected one .Professional
Maybe the site is cached on the Google data mining server... ;)Put
@ObmerkKronen, no it won't. You can pick which sites you want the cache removal to affect.Alvy
This operation takes an unreasonably long period of time on my mobile device, Android 11. I could not pick just one website.Phocis
This just worked for me in 2023 for a CSS file that was somehow being cached even after changing its version number parameter.Insipience
E
57

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.

Exerciser answered 21/2, 2016 at 13:36 Comment(9)
Confirmed working on Chrome. I almost missed this answer while skimming. Removed the comments about Firefox to help the next person. I hope this doesn't come across as conflicting with author's intent.Noteworthy
This is by far the best answer for development when you get a stuck css or js file. I find usually refreshing works fine, but sometimes for some inexplicable reason a js or css file gets stuck, and this is the only way to unstick it that I've found. Wish I could give more than 1 upvote, lol, because it's such an easy fix.Bomar
works! far better than using my fat fingers to type in javascript code.... by the way, why didn't the refresh button in the menu work in the first place...Nicholasnichole
This used to work a while back, but does not anymore on any recent version of chrome as of december 2017.Ladle
This worked for me with Chrome 2018 65.0.3325.109 on Samsung Android 5.1.1; SM-T900 Build/LMy47X. It had the additional benefit of not destroying cached data (such as localStorage values).Chlori
Does not work in Apr 2019. Chrome 73+ does not work.Nyctophobia
Deos not work (particularly refreshing CSS) on Brave 1.12.113 (chrome 84), Android 9.Chamkis
for me work fine on chrome 190801.002 and android 9.Dinesh
Did not work on Android 11. Just changed the appearance. Did not delete cache.Phocis
M
35

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!

Mundell answered 9/2, 2016 at 9:36 Comment(3)
this comment is out of date but put me on the right track. You have to enable the actual phone for debugging via Chrome first.Triplex
For detailed instructions on how to enable USB debugging on an Android phone, see: https://mcmap.net/q/89578/-how-to-find-and-turn-on-usb-debugging-mode-on-nexus-4 . And this feature is awesome for more than just the hard reload ability. Thanks!Stanleystanly
For testing in the Android emulators Ctrl+Shift+R in devtools is really nice and quick. No turning any settings on and off etc. Thanks.Hellenist
P
31

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

one

2 - tap "Site settings"

two

3 - Tap the trashcan icon

three

That's it, even the most deeply ensconsed service worker for that URL will now die.

Paquito answered 12/4, 2019 at 12:15 Comment(7)
This does not work on Chrome 73.0.3683.90 on a Samsung S9+. I have tried this over 15 times, as well as javascript:location.reload(true), and it does not work. It seems Android users cannot also be developers, according to Guug-Ul, lord of darkness.Nyctophobia
Works on my Note 8.. But I have to refresh the page after.Serra
You can also get this menu by clicking the lock icon (or whatever it displays for insecure connections) to the left of the URL.Serra
By far the best solution ! <3Pinkard
Works like a charm! Thanks for the answer...!Sexed
Easier than clearing data for all sites.Kowtow
This was the only one of the non-USB-cable solutions that worked for me. (I was developing a PWA with a Service Worker, as the author of the answer apparently also was doing.)Noddle
B
21

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.

Botha answered 4/3, 2015 at 9:11 Comment(1)
I THINK this setting is now simply called "Data Saver".Caspar
B
13

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

Belief answered 18/3, 2014 at 0:32 Comment(2)
This works. Just ?a is sufficient if you only want to reload once.Sapotaceous
This is not very feasible for reloading cached reference files (like CSS or JS), since you can't really edit the main HTML to add the ?a - of course, unless you're the site host.Minestrone
C
13

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.

Crellen answered 24/7, 2020 at 14:6 Comment(1)
This was the only solution that worked for me - enter the keys on the address bar of the page you're on, Samsung S20 FE + Chrome. Even manually typing in CSS & JS paths and refreshing, even though I could see my new code, it wouldn't apply. Tried everything else here! Note the new page will work incognito - but that's not always what you want. Thanks for this off-beat but working solution - I just wonder how long until Google disables this on Android (like using Ctrl & function keys, etc).Ecklund
C
12

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:

    enter image description here

  • 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:

    enter image description here

  • In the window that opens, click the "Network" tab and check the "Disable cache" checkbox:

    enter image description here

  • 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
Communicate answered 27/12, 2018 at 7:37 Comment(4)
awesome solution, this works mainly for "inspect" the webpage of the device directly on desktop, and you can clear cache too. Thanks.Galleywest
This is actually the most beautiful answer.Cesaro
This is the only answer that worked for me; thanks for posting!Arvillaarvin
This answer worked for me on a Google Pixel 7. Thank you!Protolanguage
S
11

As of 2018, from google help center (tested on Chrome 63) :

  1. tap on the three dots menu ;
  2. choose History > Clear browsing data ;
  3. if needed, choose the time period (above the checklist) ;
  4. uncheck all items but Cached images and files ;
  5. proceed with Clear data and confirm.

As mentioned in another answer, incognito tabs are also of great use for development.

Shrewish answered 27/1, 2018 at 8:42 Comment(5)
Note step 3: choose the time period. This did the trick for me since I was trying to clear cached pages from 3 weeks ago.Montymonument
It's not your fault but this is a pretty terrible solution as it clears the browsing data for all other sites too, which is a pain if you use your browser for anything other than dev work!Wendall
@Wendall Actually, if you select data from last hour the pain is limited. But of course this solution is quite poor, I only referenced it because it's the official one and it does work (contrarily to a few others).Shrewish
That's kind of what I mean, the fact that this is the official solution is downright embarrassing.Wendall
Great solution because this offers you the option of clearing cached data without clearing cookies or historyNorford
S
11

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.

Salcedo answered 7/8, 2019 at 23:2 Comment(1)
Perfect, that's the only solution that worked for me without USB debugging.Syst
N
8

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).

Nailbrush answered 23/5, 2017 at 17:7 Comment(4)
Interesting, I wasn't aware of this. Do you have any source that supports this claim?Aquiver
This is just observed behavior as I develop my own Javascript apps. I had to specify the CACHE-CONTROL:NO-CACHE directive in the HTTP header from my development web server to keep from going crazy over bugs that just wouldn't go away (because Chrome was insisting on caching old code). Firefox doesn't display this behavior.Nailbrush
This is the only think that worked for me out of all the answers. I had a dummy post request in javascript writing to an SQL table to check if it really refreshes and this solution got it right. Moreover subsquent site visits without the url addition are now behaving as expected. Edit: It stopped working :) I think it must have been a combination of all the stuff I tried on here hahaScull
The only effective solution I have found for this is to actually change the file name by appending a version number to it (and all the complications this involves). Looks like other developers have adopted this solution as well. So be it.Nailbrush
O
8

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.

Obstruction answered 17/10, 2019 at 19:44 Comment(1)
Underrated great answer!Vipul
E
6

Remote Debugging allows you to use the desktop dev-tools:

https://developers.google.com/chrome-developer-tools/docs/remote-debugging

Electrolytic answered 2/9, 2013 at 16:3 Comment(4)
yes thanks I know that already - should have mentioned this, but sometimes I don't want to plug it in but still have this optionBoric
You can clear the cache like this: support.google.com/chrome/answer/2392709Electrolytic
Thanks, an option without flushing the whole cache for all sites would be nice thoughBoric
This is the most reliable option when you enable Network > Disable CacheAirway
H
3

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.

Herron answered 23/8, 2020 at 21:24 Comment(2)
This works on may 2022, doing the same for css and js files independently.Intercostal
This also worked for an SVG image that was giving me a hard time. Accessing the image URL directly and reloading was already showing the new version but in the page it would not update until I tried this trick. Not sure if this applies to other image types.Ambi
C
1

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

chrome net internals

Then click the little arrow in the top right

menu

Select "clear cache" from that menu.

Cabretta answered 11/10, 2018 at 11:33 Comment(2)
In Chrome 75, chrome://net-internals says "The net-internals events viewer and related functionality has been removed..."Salcedo
@Salcedo thanks for the heads up. It looks like this method won't work any more.Cabretta
A
1

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.

Amberly answered 28/8, 2019 at 13:40 Comment(1)
Sadly this is the only one that seems to work nowadays. It does mean whenever working on css you need to keep updateing functions.php in wordpress to up the version. Yes another stupid thing about google, who fail to think and are right up there with microsoft now. But yes, an old trick :)Doerrer
E
1

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();
Euphony answered 13/2, 2021 at 8:53 Comment(0)
T
0

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.

Trojan answered 29/10, 2020 at 10:37 Comment(0)
S
0

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.

Sugden answered 19/7, 2021 at 9:35 Comment(0)
H
0
  1. Launch the Chrome Android app

  2. Tap on vertical 3dots icon the menu for more options.

  3. Select Settings from the list of options.

  4. Scroll down and tap on the Site Settings tab.

  5. Within the Site Settings open the Data Stored tab.

  6. Tap on the Site URL that you want to delete storage.

  7. Hit on the Clear & reset command button.

  8. refresh the website page.

    Site Settings in Chrome Android

Hance answered 10/10, 2021 at 14:9 Comment(0)
O
0

there are few methods to force reload chrome on mobile device:

  1. clear history (look above)
  2. use remote debugging (look above)
  3. request desktop site
  4. disable "Lite mode"
  5. open URL for .JS or .CSS then do normal reload.
Outshoot answered 1/11, 2021 at 19:37 Comment(0)
L
0

Now I have tested all server side and Android phone tricks above. Some might work for a day, but then suddenly nothing works. Does Android somehow compare the pages to their own server cache and follow some Google decisions, where and when use cache and when not ?

I have tested two phones (Android 13) and one tablet (Android 10), Chrome and Firefox with the same results.

The only way that works this moment is using incognito browser.

Lindsylindy answered 26/2, 2023 at 13:51 Comment(0)
C
-1

In chrome,simply tick "Desktop site" and then remove tick!!

Coparcener answered 29/12, 2020 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.