271

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?

Riesling
  • 6,343
  • 7
  • 29
  • 33
  • This is a duplicate of [How to refresh a web page in Chrome (Ctrl+F5 analogue) on a device without menu button?](http://android.stackexchange.com/questions/40014/how-to-refresh-a-web-page-in-chrome-ctrlf5-analogue-on-a-device-without-menu) on Android.SE. – Dan Dascalescu Feb 05 '16 at 23:23
  • 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. – Euan M Sep 09 '17 at 22:12
  • 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. – Ronnie Royston Jul 02 '19 at 04:28
  • 1
    You seem to be wrong, two years later. My experimental website is cached on refresh. – David Spector Dec 07 '22 at 20:13

25 Answers25

190

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.

Community
  • 1
  • 1
Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105
  • Are you referring to the desktop browser? There is no js console in Chrome for Android as far as i know – Riesling Sep 03 '13 at 13:23
  • 9
    Simply type it to the address bar prefixing the code with `javascript:`. – Konrad Dzwinel Sep 03 '13 at 13:36
  • 6
    Actually, you should be able to avoid `window.` part. `javascript:location.reload(true)` should do the trick. – Konrad Dzwinel Sep 03 '13 at 13:41
  • To make this easier you can add that javascript line as a bookmark so you don't have to type it in every time. – Michael Jul 14 '15 at 23:49
  • 2
    It doesn't work with Android :-( Not better via privacy settings > clear cache. –  Jan 09 '16 at 16:51
  • `javascript:location.reload(true)` worked for me on Android 7.0 in Chrome v55 – vitaly87 Dec 23 '16 at 18:22
  • 8
    didn't work for me on chrome v55.0.2883.91/android5.1.1 – Kev Jan 09 '17 at 13:42
  • 30
    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. – Scott Wilson Mar 09 '17 at 06:06
  • 2
    Since everyone keeps saying it didn't work: It worked fine for me on Chrome 58 on Android 6. – Nateowami Jun 26 '17 at 05:47
  • Works just fine on Chrome 58 on Android 6.0.1 (Nexus 5) – Vahid Amiri Jun 26 '17 at 23:39
  • 53
    I open up an Incognito window – Deepak Kamat Oct 21 '17 at 14:56
  • For testing purpose don't forget to disable the server side caching headers. Maybe overwrite or disable .htaccess caching headers – Sjaak Wish Dec 24 '17 at 13:23
  • And how do you do this from the Android Chrome browser? – WebDude0482 Apr 01 '19 at 15:38
  • 4
    On my phone, the `true` flag is not honored, ergo that is just the equivalent of tapping the reload icon. – yPhil Apr 12 '19 at 12:21
  • The Parameter doesn't do anything in Chrome, and the default behavior was changed a while ago: https://bugs.chromium.org/p/chromium/issues/detail?id=670237 – EricLaw May 06 '20 at 17:44
  • for me don't work on chrome 190801.002.only soft refreshed not hard. – nekooee Oct 26 '20 at 08:41
  • 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). – Meryan Apr 03 '21 at 20:22
  • 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. – WoodrowShigeru Jul 19 '21 at 09:33
  • MDN: Pass true to force a reload bypassing cache [...] Only supported in **Firefox**. – Benjamin Bræstrup Sayoc Jun 13 '23 at 21:01
178

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.

Michael
  • 5,994
  • 7
  • 44
  • 56
  • 3
    @Kev Neither for me. – Ricky Boyce Apr 07 '17 at 13:17
  • 2
    Yes, this one is working for me on Android 6.0.1 with Chrome 59. – Avio Jul 20 '17 at 14:01
  • 6
    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. – Ogier Schelvis Sep 15 '17 at 13:18
  • I use it more often, if it isn't working for you probably the cache is on the server and not the browser. – Deepak Kamat Oct 21 '17 at 14:57
  • 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. – Juha Untinen Nov 12 '17 at 19:33
  • Juha: I had the same result: works on incognito, doesn't do jack for the normal version. – Capagris Dec 06 '17 at 04:03
  • 5
    It will clear cache in incognito mode only the first time. After that the same issue appears – Mara Jun 02 '18 at 10:00
  • 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 temporarily – yPhil Apr 12 '19 at 12:22
  • 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. – dkocich Sep 15 '21 at 06:44
91

Also an option:

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

and then reload the page.

Alec
  • 1,986
  • 4
  • 23
  • 47
checkmate711
  • 3,301
  • 2
  • 35
  • 45
  • 2
    Now its changed to `Clear Browsing Data`, where you can check `clear cache` using check box. – Shaiju T Dec 03 '15 at 07:39
  • 1
    No, and then, KILL Chrome, relaunch Chrome, then reload the page. Yeah, it just got worse. – ADTC Aug 02 '16 at 16:27
  • 4
    *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! – ADTC Oct 23 '16 at 08:47
  • 1
    *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. – ADTC Oct 23 '16 at 08:50
  • 4
    This will clear the cache from ALL sites, not just the inspected one . – Obmerk Kronen Dec 31 '16 at 23:52
  • 1
    Maybe the site is cached on the Google data mining server... ;) – Juha Untinen Nov 12 '17 at 19:35
  • @ObmerkKronen, no it won't. You can pick which sites you want the cache removal to affect. – yaakov Nov 20 '17 at 18:25
  • This operation takes an unreasonably long period of time on my mobile device, Android 11. I could not pick just one website. – David Spector Dec 07 '22 at 20:26
  • This just worked for me in 2023 for a CSS file that was somehow being cached even after changing its version number parameter. – Pikamander2 Jun 17 '23 at 11:28
56

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.

Ishmaeel
  • 14,138
  • 9
  • 71
  • 83
lucoweb
  • 685
  • 5
  • 5
  • 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*. – Ishmaeel Feb 03 '17 at 10:41
  • 1
    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. – Lizardx Feb 28 '17 at 22:28
  • 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... – user7180 Mar 24 '17 at 10:05
  • 13
    This used to work a while back, but does not anymore on any recent version of chrome as of december 2017. – Capagris Dec 06 '17 at 04:03
  • 1
    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). – CODE-REaD May 09 '18 at 16:11
  • 5
    Does not work in Apr 2019. Chrome 73+ does not work. – Incorporeal Logic Apr 26 '19 at 19:16
  • Deos not work (particularly refreshing CSS) on Brave 1.12.113 (chrome 84), Android 9. – Ji_in_coding Aug 28 '20 at 14:44
  • for me work fine on chrome 190801.002 and android 9. – nekooee Oct 26 '20 at 08:44
  • 1
    Did not work on Android 11. Just changed the appearance. Did not delete cache. – David Spector Dec 07 '22 at 20:27
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!

Aakash Goel
  • 1,169
  • 2
  • 13
  • 22
  • 4
    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. – Deborah Aug 28 '16 at 10:42
  • For detailed instructions on how to enable USB debugging on an Android phone, see: https://stackoverflow.com/a/16707217/1024735 . And this feature is awesome for more than just the hard reload ability. Thanks! – kevinmicke Aug 29 '18 at 17:06
  • 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. – Rainer Schwarze Feb 19 '19 at 16:28
30

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.

yPhil
  • 8,049
  • 4
  • 57
  • 83
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.

heidgert
  • 451
  • 4
  • 6
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

Lucas Zamboulis
  • 2,494
  • 5
  • 24
  • 27
Banana Phobia
  • 147
  • 1
  • 3
  • This works. Just `?a` is sufficient if you only want to reload once. – Dan Dascalescu Feb 05 '16 at 23:25
  • 13
    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. – ADTC Oct 23 '16 at 08:48
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
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
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.

Skippy le Grand Gourou
  • 6,976
  • 4
  • 60
  • 76
  • 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. – Dror Jul 27 '18 at 09:56
  • 3
    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! – GameKyuubi Jan 28 '19 at 22:53
  • @GameKyuubi 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). – Skippy le Grand Gourou Jan 29 '19 at 06:25
  • That's kind of what I mean, the fact that this is the official solution is downright embarrassing. – GameKyuubi Jan 29 '19 at 08:50
  • Great solution because this offers you the option of clearing cached data without clearing cookies or history – Roland Nov 24 '20 at 15:13
11

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.

namp
  • 111
  • 2
  • 2
  • 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). – Jon Dec 16 '20 at 22:19
9

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.

Bort
  • 493
  • 1
  • 8
  • 26
7

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

Greg Searle
  • 459
  • 5
  • 3
  • Interesting, I wasn't aware of this. Do you have any source that supports this claim? – Antoine Oct 12 '17 at 20:56
  • 3
    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. – Greg Searle Oct 30 '17 at 20:55
  • 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 haha – Majte May 27 '22 at 12:37
  • 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. – Greg Searle May 29 '22 at 17:58
6

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

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

6

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Novasol
  • 887
  • 10
  • 17
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.

user1937747
  • 160
  • 6
  • This works on may 2022, doing the same for css and js files independently. – Emeeus May 22 '22 at 02:55
  • 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. – Besworks Jun 12 '22 at 01:58
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.

Tom Kay
  • 1,512
  • 15
  • 25
  • 1
    In Chrome 75, chrome://net-internals says "The net-internals events viewer and related functionality has been removed..." – Bort Jul 02 '19 at 13:15
  • @Bort thanks for the heads up. It looks like this method won't work any more. – Tom Kay Jul 29 '19 at 08:13
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.

  • 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 :) – Gavin Simpson Mar 05 '20 at 10:01
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();
MSS
  • 3,520
  • 24
  • 29
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.

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.

WoodrowShigeru
  • 1,418
  • 1
  • 18
  • 25
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

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.
uingtea
  • 6,002
  • 2
  • 26
  • 40
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.

Cordite
  • 11
  • 1
-1

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

PCcloob.Ir
  • 87
  • 12