opCache vs LSCache

I have a lot of sites running custom PHP (7.2) and with OpCache enabled and I am getting memory usage down from ~3MB to ~0.8MB and execution times down from 0.04s to 0.01s, which is great.

My hosting company have recently swapped out Apache for LiteSpeed and now LSCache is available and can be configured in .htaccess.

I have searched for a comparison between opCache and LSCache but can’t find anything. I broadly understand how OpCache works. Are opCache and LSCache fundamentally different? If so, how? Can they be used together?

My hosting company implied LSCache is better for static sites but they are understandably limited in what information they give out.

I like that OpCache just works and the memory footprint and execution times I am achieving look about as low as they can go. I am wondering if looking into using LSCache too/sintead of is worth it.

Completely different concepts. OPcache works within PHP, LSCache works within the web server to cache served html pages, images, CSS files, etc.

1 Like

Thank you.

Does LSCache cache them in memory then? Else I don’t see how it’d be faster.

Well for HTML pages that are generated by something like PHP it can already be faster if you store them on disk because then you can serve them immediately without having PHP do query databases, render templates, maybe call some other services, etc.

Caching is a solution to specific problems, not some blanket solution you can throw at anything and expect it to solve all your performance problems. Even if it does, you’ll get other problems in return (cache invalidation).

Thanks, so it sounds a bit like mod_cache.

While not a blanket solution it does depend on the caching you choose. How complex it is to integrate and how much it will improve performance depends on the type of cache and your use case. There is a big difference in enabling OpCache (really easy, wide use-case) and implementing caching at an application level using something like PHPFastCache with date-sensitive data and a CMS (can be tricky to get right, depends on website traffic as to whether it’s worth it). And there is a big performance difference in using file-based cache storage and memory-based cache storage.

So, before you consider a caching type you need to know how it works, hence the question.

I’ll have a play around with it. Thanks for your help.

1 Like

LSCache also called as LiteSpeed Cache is a high-performance page cache which can be highly customizable for dynamic content that is built into LiteSpeed Web Server. With this cache, you can improve up your WordPress, Joomla and other dynamic websites.

A PHP extension, OPcache is a good solution for the issues on performance of your website. It helps in improving the PHP performance by storing compiled script byte code in shared memory. With this you don’t need to load PHP and parse scripts on each request.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.