- Where Does Chrome Keep Its Cache in Ubuntu?
- Explore this article
- 1 Location of Browser Cache
- 2 Chrome’s Application Cache
- How to clear Chromium Browser cache?
- 2 Answers 2
- Chromium
- Installed from regular package
- Installed from snap
- Google Chrome
- Linux – what is the path to Chrome cache on Ubuntu
- Best Solution
- Related Solutions
- Introduction
- How to set it?
- HTML meta tags vs HTTP response headers
- Verifying the actual HTTP response headers
- I want to set those headers on file downloads too
Where Does Chrome Keep Its Cache in Ubuntu?
As you visit websites with your Chrome browser, information is stored or cached in special directories on your Ubuntu PC. The data saved can include HTML code, scripts, CSS files, images and multimedia files. Chrome maintains an additional cache of files in another location, which it uses whenever you access an HTML5 Web application.
Explore this article
1 Location of Browser Cache
Chrome’s cached website data is stored in your Home directory, but is hidden from sight within the .cache/google-chrome/ Default folder. This folder also contains another cache where multimedia files are temporarily stored. You can explore both cache locations using Ubuntu’s Files application. Launch Files and then press «Ctl-H» to make all hidden folders visible. Click «Home | .cache | google-chrome | Default | Cache” to view the website data cache. The full path for the browser cache is:
Multimedia files are kept in in the following folder:
The term «$USER» is a system variable that contains your user name. For example, if your user name is «linuxmaven,» the location of the cache is:
2 Chrome’s Application Cache
When you use a Web app like Google Drive, Gmail, or YouTube, Chrome saves some of the app’s data and JavasScript code to your hard disk. The data in this cache helps speed up the function of the HTML5 Web apps you use or helps enable them to run off-line. Chrome’s HTML5 application cache data is kept in the hidden .config folder. The full path to the application cache is:
How to clear Chromium Browser cache?
I’m trying to clear my Chromium browser cache using CLI on Gallium OS (based on Xubuntu ). What command should I use?
2 Answers 2
On Linux you can clear the browser cache using the following command, after closing the browser:
Chromium
The browser cache is stored in different directories depending on whether Chromium is installed as a regular package or as a snap. Run
to find out which one your system is using. Examples:
/usr/bin/chromium -> traditional package /snap/bin/chromium -> snap
Installed from regular package
Installed from snap
rm -rf ~/snap/chromium/common/.cache/chromium
Google Chrome
Hmm. On Ubuntu 20.04 installed from snap ~/snap/chromium/common/.cache/chromium did not exist on my system. So rm -rf ~/snap/chromium/common/.cache worked for me.
Assuming you have the ‘traditional package’ for chromium,
is not enough to clear «everything». I noticed after running that command that cookies were indeed cleared but stored values for forms were still there and browser history was still there as well. The following clears those as well:
That .config folder has a lot of different subfolders but after deletion and upon restarting chromium, they are all repopulated. So a complete command to clear everything in chromium is:
rm -rf ~/.cache/chromium && rm -rf ~/.config/chromium
Yes, granted the OP did not ask for «everything» but if you are reading this question that is possibly what you might be trying to do.
Linux – what is the path to Chrome cache on Ubuntu
I want to be able to clear cache (both browser’s own cache and possible offline cache manifests) through the command line.
Best Solution
Chrome Cache located into Path:
$HOME/.cache/google-chrome/Default/
To delete Web browsing Cache:
rm -rf $HOME/.cache/google-chrome/Default/Cache/
To delete video and Music (Media) cache:
rm -rf $HOME/.cache/google-chrome/Default/Media\ Cache/
Also there another cache Folder under Profile 2 Folder:
rm -rf $HOME/.cache/google-chrome/Profile\ 2/Cache/
Notice: Do not remove all (Folder, Files) under google-chrome Folder like this
rm -rf $HOME/.cache/google-chrome/
Just remove files under Folder and keep Folder Empty.
Related Solutions
How do we control web page caching, across all browsers
Introduction
The correct minimum set of headers that works across all mentioned clients (and proxies):
Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0
The Cache-Control is per the HTTP 1.1 spec for clients and proxies (and implicitly required by some clients next to Expires ). The Pragma is per the HTTP 1.0 spec for prehistoric clients. The Expires is per the HTTP 1.0 and 1.1 specs for clients and proxies. In HTTP 1.1, the Cache-Control takes precedence over Expires , so it’s after all for HTTP 1.0 proxies only.
If you don’t care about IE6 and its broken caching when serving pages over HTTPS with only no-store , then you could omit Cache-Control: no-cache .
Cache-Control: no-store, must-revalidate Pragma: no-cache Expires: 0
If you don’t care about IE6 nor HTTP 1.0 clients (HTTP 1.1 was introduced in 1997), then you could omit Pragma .
Cache-Control: no-store, must-revalidate Expires: 0
If you don’t care about HTTP 1.0 proxies either, then you could omit Expires .
Cache-Control: no-store, must-revalidate
On the other hand, if the server auto-includes a valid Date header, then you could theoretically omit Cache-Control too and rely on Expires only.
Date: Wed, 24 Aug 2016 18:32:02 GMT Expires: 0
But that may fail if e.g. the end-user manipulates the operating system date and the client software is relying on it.
Other Cache-Control parameters such as max-age are irrelevant if the abovementioned Cache-Control parameters are specified. The Last-Modified header as included in most other answers here is only interesting if you actually want to cache the request, so you don’t need to specify it at all.
How to set it?
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies.
Using Java Servlet, or Node.js:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setHeader("Expires", "0"); // Proxies.
Response.Cache.SetCacheability(HttpCacheability.NoCache); // HTTP 1.1. Response.Cache.AppendCacheExtension("no-store, must-revalidate"); Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies.
// `response` is an instance of System.Net.Http.HttpResponseMessage response.Headers.CacheControl = new CacheControlHeaderValue < NoCache = true, NoStore = true, MustRevalidate = true >; response.Headers.Pragma.ParseAdd("no-cache"); // We can't use `response.Content.Headers.Expires` directly // since it allows only `DateTimeOffset?` values. response.Content?.Headers.TryAddWithoutValidation("Expires", 0.ToString());
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies.
// using Microsoft.Net.Http.Headers Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate"; Response.Headers[HeaderNames.Expires] = "0"; Response.Headers[HeaderNames.Pragma] = "no-cache";
Response.addHeader "Cache-Control", "no-cache, no-store, must-revalidate" ' HTTP 1.1. Response.addHeader "Pragma", "no-cache" ' HTTP 1.0. Response.addHeader "Expires", "0" ' Proxies.
headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. headers["Pragma"] = "no-cache" # HTTP 1.0. headers["Expires"] = "0" # Proxies.
response = make_response(render_template(. )) response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. response.headers["Pragma"] = "no-cache" # HTTP 1.0. response.headers["Expires"] = "0" # Proxies.
response["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. response["Pragma"] = "no-cache" # HTTP 1.0. response["Expires"] = "0" # Proxies.
request.response.headerlist.extend( ( ('Cache-Control', 'no-cache, no-store, must-revalidate'), ('Pragma', 'no-cache'), ('Expires', '0') ) )
responseWriter.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. responseWriter.Header().Set("Pragma", "no-cache") // HTTP 1.0. responseWriter.Header().Set("Expires", "0") // Proxies.
Using Clojure (require Ring utils):
(require '[ring.util.response :as r]) (-> response (r/header "Cache-Control" "no-cache, no-store, must-revalidate") (r/header "Pragma" "no-cache") (r/header "Expires" 0))
Using Apache .htaccess file:
Header set Cache-Control "no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires 0
HTML meta tags vs HTTP response headers
Important to know is that when an HTML page is served over an HTTP connection, and a header is present in both the HTTP response headers and the HTML tags, then the one specified in the HTTP response header will get precedence over the HTML meta tag. The HTML meta tag will only be used when the page is viewed from a local disk file system via a file:// URL. See also W3 HTML spec chapter 5.2.2. Take care with this when you don’t specify them programmatically because the webserver can namely include some default values.
Generally, you’d better just not specify the HTML meta tags to avoid confusion by starters and rely on hard HTTP response headers. Moreover, specifically those tags are invalid in HTML5. Only the http-equiv values listed in HTML5 specification are allowed.
Verifying the actual HTTP response headers
To verify the one and the other, you can see/debug them in the HTTP traffic monitor of the web browser’s developer toolset. You can get there by pressing F12 in Chrome/Firefox23+/IE9+, and then opening the «Network» or «Net» tab panel, and then clicking the HTTP request of interest to uncover all detail about the HTTP request and response. The below screenshot is from Chrome:
I want to set those headers on file downloads too
First of all, this question and answer are targeted on «web pages» (HTML pages), not «file downloads» (PDF, zip, Excel, etc). You’d better have them cached and make use of some file version identifier somewhere in the URI path or query string to force a redownload on a changed file. When applying those no-cache headers on file downloads anyway, then beware of the IE7/8 bug when serving a file download over HTTPS instead of HTTP. For detail, see IE cannot download foo.jsf. IE was not able to open this internet site. The requested site is either unavailable or cannot be found.
Javascript – How to force the browser to reload cached CSS and JavaScript files
This solution is written in PHP, but it should be easily adapted to other languages.
The original .htaccess regex can cause problems with files like json-1.3.js . The solution is to only rewrite if there are exactly 10 digits at the end. (Because 10 digits covers all timestamps from 9/9/2001 to 11/20/2286.)
First, we use the following rewrite rule in .htaccess:
RewriteEngine on RewriteRule ^(.*)\.[\d]\.(css|js)$ $1.$2 [L]
Now, we write the following PHP function:
/** * Given a file, i.e. /css/base.css, replaces it with a string containing the * file's mtime, i.e. /css/base.1221534296.css. * * @param $file The file to be loaded. Must be an absolute path (i.e. * starting with slash). */ function auto_version($file) < if(strpos($file, '/') !== 0 || !file_exists($_SERVER['DOCUMENT_ROOT'] . $file)) return $file; $mtime = filemtime($_SERVER['DOCUMENT_ROOT'] . $file); return preg_replace('<\\.([^./]+)$>', ".$mtime.\$1", $file); >
Now, wherever you include your CSS, change it from this:
This way, you never have to modify the link tag again, and the user will always see the latest CSS. The browser will be able to cache the CSS file, but when you make any changes to your CSS the browser will see this as a new URL, so it won’t use the cached copy.
This can also work with images, favicons, and JavaScript. Basically anything that is not dynamically generated.