tmpfs as cache location for internet browsers

Linux administration

How set the tmpfs under Linux Debian

fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>

tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=20G 0 0
#
tmpfs /var/web-cache/vivaldi/username tmpfs defaults,noatime,uid=username,gid=usergroup,nosuid,size=500M 0 0
tmpfs /var/web-cache/firefox/username tmpfs defaults,noatime,uid=username,gid=usergroup,nosuid,size=500M 0 0
tmpfs /var/web-cache/opera/username tmpfs defaults,noatime,uid=username,gid=usergroup,nosuid,size=500M 0 0

Manage cache directories

Under root permissions create following directories:

# sudo mkdir -p /var/web-cache/vivaldi/username
# sudo mkdir -p /var/web-cache/firefox/username
# sudo mkdir -p /var/web-cache/opera/username

And change user’s permissions:

# sudo chown username:usergroup /var/web-cache/vivaldi/username
# sudo chown username:usergroup /var/web-cache/firefox/username
# sudo chown username:usergroup /var/web-cache/opera/username

Setting cache location in browsers

After the preparation on the OS side it is necessary to prepare the browser side, the location of the cache directory should be changed in the settings of a browser.

Firefox

In the Firefox browser it is very easy to change the location of cache directory inside the configuration settings, just enter the following URL in the address bar of a browser:

about:config

You will see a page like that:

Just accept and go further to configuration settings where you will find the records related to browser’s cache, two of those records are interesting:

browser.cache.disk.capacity

browser.cache.disk.parent_directory

You can set those records to your own values according to directories in /var that has been prepared earlier.

The sample of such configuration is below:

Chromium based browsers Vivaldi, Opera, Chrome etc.

Command line argument passed to the executable of the browser:

--disk-cache-dir="/var/web-cache/vivaldi/username" 
--disk-cache-size=104857600

Cache directory

/home/username/.cache/vivaldi
/home/username/.cache/vivaldi-snapshot
Change location:
# cd ~/.cache/
# rm -fr vivaldi-snapshot/
# ln -s /var/web-cache/vivaldi/username/ vivaldi-snapshot
Sample of output from ls -ls command after links are applied

Configuration directory

/home/username/.config/vivaldi
/home/username/.config/vivaldi-snapshot

Additional information

How to speed up the Vivaldi web browser