Reputation: 643
How to disable cache on chrome for Android?
I change my page content, and refresh the page, but the content still is old.
I have set the nginx config like below, but it has no effect.
#disable cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma no-cache;
add_header Expires 0;
Is there a way to get my newest page without manually clear cache again and again?
Upvotes: 35
Views: 46580
Reputation: 572
The following bash script will rename
<script src="path/to/app.js"></script>
to
<script src="path/to/app.js?t=18:15:45></script>
in an index.html
file, which will prevent mobile caching.
#!/bin/bash
time=$(date +"%T")
sed -i "s/app.js/app.js?t=${time}/" ./path/to/index.html
Upvotes: 0
Reputation: 2646
This may not be the easiest way, but it will 100% work and should be part of your development setup anyway.
Using Google Chromes web tools on Windows or Mac will allow you to do "remote debugging".
Inspect
Upvotes: 24
Reputation: 1003
Currently there is no way to disable cache on chrome for Android but it is possible to clear the cache.
UPDATE: As of now there is a way to disable cache with requires your phone to be connected and needs remote debugging, please refer to Dean Meehan's answer for more info
Follow these steps to clear the cache.
http://www.refreshyourcache.com/en/chrome-android/
Upvotes: 9
Reputation: 285
I know the question is asking about disabling cache on chrome for Android, but this may help people looking for a solution to mobile development.
To see changes on your website with your Android device use the New incognito tab in chrome web menu.
IMPORTANT: To see new changes after viewing with incognito, you must close the incognito mode completely and reopen due to the current tab also caching.
Upvotes: 10
Reputation: 11943
To disable the cache first you'll have to disable scripts / css caching on the ones you are editing.
In order to do that, add a timestamp to your file inclusions :
<link rel='stylesheet' href='/static/css/main.css?t={{ts}}'/>
<script type='text/javascript' src='/static/scripts/main.js?t={{ts}}'></script>
{{ts}}
being a timestamp (I'm using jinja templating).
Then if you edit your html page, you could change the request adding a random parameter to it as such :
test 1 : mywebsite.com/this_page
test 2 : mywebsite.com/this_page/?i=1
test 3 : mywebsite.com/this_page/?i=2
...
It's more a hack than a real solution, but chrome kindly ignores the cache-control
meta, so there aren't lots of clean way to do it.
Upvotes: 3
Reputation: 17
Download this app : App Cache Cleaner
You may as well disable Chrome's Data Compression policy and preloading of pages.
As of now, there are no 'disable cache' option in chrome
PS:i cud not show pictures because of my low rep, help me increase that too ;p
Upvotes: -1