The situation is:
I' m building a PHP application and need http caching.
Varnish is great and lots of people tell me that Varnish stores the cached data in RAM. I want it to cache on hard disk.
Is there any way to store the Varnish cache-data on hard disk?
There are 2 main ways Varnish caches your data:
You are asking for #2. In this method Varnish will always write the cache to disk and rely on the OS virtual memory subsystem to keep the most used disk pages in RAM.
If you are using Red Hat/CentOS, edit your /etc/sysconfig/varnish
If not, you want something like this:
50% will use half the available disk. You can also use 10G etc. When using the file storage it is recommended to mount /var/lib/varnish to a non-journaled file system (eg ext2) and to use noatime and nodiratime when mounting the FS.
Varnish stores data on disk and then pulls it into RAM to accelerate requests. Short of modifying the source code, I doubt what you're asking for is possible.
Take a look at the Architect Notes. A quick read and you should understand the basics quite clearly. The most important bit to note is that Varnish doesn't differentiate between disk and memory, that's the kernel's job.