This looks like an X-Y problem to me. Please take a step back and describe the actual problem you're trying to solve instead of what you perceive as the solution.
Besides, website caching doesn't work the way you seem to expect it to, and website performance is a rather complex beast anyway, with lots of moving parts (database access, server-side scripts, client-side scripts, static file access, hardware and network performance, ...). I seriously doubt that it's even possible to write the kind of silver bullet file cache you're asking for.