You want to do something as simple as moving the directory Chromium uses for cache and you wind up learning more about the XDG Base Directory Specification than you wanted. I wanted to move Chromium’s cache so that I didn’t back up these unimportant and constantly changing files during my hourly backups. Backing up all these files not only takes up extra space, but it also annoyingly slows down the backup.
I needed to figure out where the cache directory was located and how to move it. Moving the cache directory in Firefox is simple, you just goto about:config and change the value of browser.cache.disk.parent_directory. Heading over to the Chromium Project I found a page that described where the cache was located for Linux:
It turns out that Chromium follows the XDG Base Directory specs. Applications that follow these specs will store config, data and cache directories in the locations specified by their corresponding environment variables. The thought behind this structure is to clean up the user directories and make the different desktop managers play nicely with each other. From the specification:
$XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
$XDG_DATA_DIRS defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. The directories in $XDG_DATA_DIRS should be seperated with a colon ‘:’. If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
$XDG_CONFIG_DIRS defines the preference-ordered set of base directories to search for configuration files in addition to the $XDG_CONFIG_HOME base directory. The directories in $XDG_CONFIG_DIRS should be seperated with a colon ‘:’ If $XDG_CONFIG_DIRS is either not set or empty, a value equal to /etc/xdg should be used.
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
Bingo! $XDG_CACHE_HOME sets the location of the cache files and if it isn’t present it defaults to where the Chromium project says the cache files are stored.
The final piece of the puzzle is figuring out where to put the environment variable so that next time you log into your desktop it actually gets set. This is where the Ubuntu Community Documentation saved me. It turns out that there is a file in each individuals home directory called:
It may or may not be present. If it isn’t just create it. This file is specifically for setting environment variables. It’s not a script file like .profile, so stick to variable assignments.
So I set:
and deleted the default .cache directory in my home directory. Now when I back up my home directory I don’t waste time and space backing up the cache files.