For the usual reasons we want to cache certain resources browser side, e.g. list of products bought in the past. Context is a web application, accessed via the internet.

This list is confidential in my case, and I want to mitigate the case where an attacker get physical access to the (os password locked) machine or to the hard drive.

Are there standard strategies/JS libs/browser support for such scenarios? It seems browsers in general will cache files in an unprotected way (not encrypted essentially).

Full disk encryption or any os level strategy is not an option obviously - no control over who uses my web application. I still want to protect their data.

  • 2
    Can you explain why common drive encryption is not sufficient in this case, i.e. why do you need something which specifically protects the browser data instead protecting the contents of the disk in general? Apr 21, 2021 at 19:54
  • 1
    Are we talking about one/your computer or any browser using a certain web site? If it is only your or a small number of computers you should simply use a full disc encryption. Just protect all data stored in it.
    – Robert
    Apr 21, 2021 at 19:57
  • It is going to be thousands of computers to which I dont have access, not realistic to tell all of them to encrypt - that's a service I want to provide, rather.
    – Nicolas B
    Apr 22, 2021 at 6:14

1 Answer 1


If you control the system

Besides cached files that you see there can be other places where browser data can be found:

  • System swap file
  • Temporary files (this is not the same as cache)
  • Data in the deleted (some files can be restored after deletion)

That's why, if you have some sensitive data in cached files, caring about cache files only is not sufficient.

That's why consider using whole disk encryption. On Windows it can be BitLocker, on Linux some solution based on LUKS like dm-crypt.

If the whole disk is encrypted, then you don't need to care about any temporary files and deleted files.

If you don't control the system, e.g. cache on user device

A solution depends on what threats you see.

  1. If disclosure of cached data means that user will loose let say 100'000 USD, then a very efficient solution is to inform users how they can encrypt their disks.

  2. If disclosure of cached data is less expensive: Generate a key pair. Send public key to the server. On the server encrypt data with public key. In browser, before displaying data, decrypt them with user private key. Such data in cache cannot be decrypted by anyone. To access private key user will be asked once for a password. If device is stolen, nobody will be able to use private key because this requires the password. If the password is random and long enough, it will be unbreakable. Separate data from code. Encryption of code makes no sense. Encrypt the data only. But: When browser decrypted data and displays them to the user, they are present in the plain form in the browser DOM. If the device swaps memory, such data can be written to the swap file in the plain form. Means, this approach is not as secure as the full disk encryption.

  3. If the data disclosure will not cost much, i.e. if the data disclosure does not give an attacker much benefits, then experienced attackers will not spend their time on retrieving such data. Then you protect against simple threats only, e.g. against advanced users that are aware of browser cache, but don't know much about technologies used in browser. Then obfuscation might be sufficient. Simple viewing of cached files will not give such unskilled "attackers" any info.

  • 1
    Whats a single good reason to NOT use full disk encryption?
    – john doe
    Apr 22, 2021 at 3:46
  • @johndoe: It depends on the person. For instance, some people may have many operating systems on the same device and may want to use the same partition in multiple OSs, e.g. a partition with their photo archive. Then in one OS it can me mounted automatically, on other OSs user may need to provide password each time. To me it is not a good reason not to use full disk encryption, but for some persons it might be a reason.
    – mentallurg
    Apr 22, 2021 at 21:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .