Thursday, February 7, 2013

Configuring Google Chrome cache size in Mac

Just bought a new MacBook Air for ~S$2100 (inclusive of GST) and it felt great! I initially had a struggle with the high cost, but finally decided to part with my money for this sexy machine. It is indeed awesome, sleek, easy to use and definitely worth every cent that is spent!

The first thing I had to install is Chrome. I recently found that Google Chrome stores old copies of itself after every auto-update, even if the update is very minor, for e.g., from version 23.0.0.1 to 23.0.0.2. Each copy could take up 100-200 MB and several of them could easily add up to say, 1 GB of disk space! These old copies could be safely deleted if you care about the wastage of disk space.

To do so, if you're using Windows, you can simply go to C:\Program Files (x86)\Google Chrome\ (or a similar path) and delete the folders with versions as their names. If you're using Mac, you can go to /Applications/Google Chrome.app/Contents/Versions (if you installed in that location). Well, actually I'm not even sure whether the Mac version of Chrome stores old copies of itself in there. And sorry folks, I don't know the location for the *nix version. :(

Another nuisance for a disk-space-conscious person like me is that Chrome is configured by default to use an unlimited amount of disk space for its cache! Fortunately, you can limit the cache size by adding the command line argument --disk-cache-size=XX in the shortcut to Chrome (in Windows), where XX is the size in MB. In Mac, this is a bit more involved. But fret not, just follow these steps:

  1. Close all Chrome windows and quit the entire application before you proceed with the steps below.
  2. Go to /Applications/Google Chrome.app/Contents and open the file Info.plist using a text editor.
    • In case you have difficulty in even going to that folder, you'd have to select "Browse Package Contents" after right-clicking on Google Chrome.app (the large Chrome icon) in Applications.
  3. Find the following text:
    • <key>CFBundleExecutable</key>
    • <string>Google Chrome</string>
  4. Replace Google Chrome with wrapper and save the file.
  5. Next, go to ..../Contents/MacOS and create a plain-text file named wrapper
  6. In the file wrapper, add the following contents and save it:
    • #!/bin/sh
      /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome "$@" --disk-cache-size=50 &
  7. Please ensure the path to Google Chrome.app is exactly correct. Every single space counts. In case you're wondering, the sequence "\ " is used to escape a single space. If you don't know what escaping is, it's fine. Just take it that you have to replace all spaces with "\ " (without the quotes). You can also change the number 50 if you wish.
  8. Viola! You're done. Click the Chrome icon in your dock to open it.

No comments:

Post a Comment