macOSTIPS & GUIDES

How to stop and disable Quick Look cache in macOS

Quick Look in macOS is handy for previewing files, but here’s why you may want to clear its cache from time to time.

We’ve covered previously how to use Quick Look in macOS. Using this technology, you can gain fast previews of the contents of files without having to open them by selecting them and pressing the spacebar.

Each time you do that, Apple generates a small image to represent the current items displayed in the Quick Look window. Those images gets cached and over time can build up to an appreciable size.

In some cases, if the files are stored on a non-encrypted volume, they can also leak sensitive data, which you don’t want to have happen. For both of these reasons, you may want to delete the Quick Look cache data off your Mac from time to time.

Stored files

As of macOS Ventura, Quick Look stores several cached files in /private/var/folders/ in a folder with a randomized name, usually two characters, then another folder with a long randomized name, and a folder inside of that named “C“. So, for example, /private/var/folders/x8/067t9c811b38449zf9swlz980000gn/C.

Inside the “C” folder is another folder named “com.apple.quicklook.ThumbnailsAgent“, and inside of that the cache folder itself is one named “com.apple.QuickLook.thumbnailcache“.

The macOS quicklook.ThumbnailsAgent runs in the background on your Mac as an XPC service (called the Quick Look Server) which waits for a signal to prepare a Quick Look thumbnail. This happens every time you select items in the Finder or another app that supports it and press the spacebar.

The agent then generates and caches the Quick Look image to display in the Quick Look window. For photos, these files can also contain paths to the original file on the filesystem, which you may not want others to have access to.

If the selected documents are text, the cached thumbnail may also contain small images of the actual text of those documents, which then get leaked into the cached folder.

If a document or image contains sensitive personal info, and you Quick Look it, these cache files can make copies of that info which gets leaked into the cache. Once that happens, other apps or people with access to the Mac can go in and read the cached data.

These files include thumbnails, data, several SQLite databases, and other files.

qlmanage tool

Apple ships a binary UNIX tool with macOS called qlmanage which lives at /usr/bin/qlmanage on your Startup Disk’s filesystem. The /usr folder and sub-folders are normally hidden, so you’ll have to show invisible files in Terminal or Finder first in order to see the folder.

To get more info on the qlmanage tool, in Terminal type man qlmanage and press Return

There are several flags you can pass to qlmanage to tell it what to do. A few of these commands include:

-r - Resets the Quick Look Server and all of the caches files. 
-m - Gets info about Quick Look Server including all QL generators which are plugins for reading custom data with Quick Look. 
-t - Display generated Quick Look thumbnails for selected files. 
-p - Display generated Quick Look previews for selected files.

Clearing the cache

To clear your Quick Look cache on macOS, in Terminal type qlmanage -r cache and press Return.

Note that after clearing the cash, the next time you Quick Look a large file or files, there may be a slight delay. This is because the selected app may have to regenerate the previews and thumbnails, and if those images are large it can take a while.

Disabling the Quick Look cache

There is no direct command for stopping the XPC service that runs in the background to generate Quick Look previews. If you kill the com.apple.quicklook.ThumbnailsAgent using Activity Monitor, it won’t be stopped for long as the OS will simply restart it automatically,

If you want to disable the Quick Look cache entirely, you’ll need to set aside the Quick Look generators themselves located in System/Library/QuickLook/. In particular Text.qlgenerator and Image.qlgenerator.

To completely disable the feature you’ll need to set them all aside so the thumbnails never get generated to begin with, and subsequently leaked out into macOS filesystem where they could easily be discovered.

Also note that third-party Quick Look generators may also be installed in the user’s home folder at /Users/~/Library/QuickLook/.

We don’t recommend doing this, since in general messing with parts of the OS isn’t a good idea and can break the OS or render your Mac unbootable. But if you want to disable QuickLook, the option is there.

You may also like

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments