#FasterFriday – Using LSCache to speed-up your website
What is LSCache?
LSCache (LiteSpeed Cache) is a tool for accelerating dynamic (generated by code) web site content and is part of the LiteSpeed Enterprise web server software that some web hosts (including us) use to handle user requests to your website.
As it is built in to the LiteSpeed server itself, there’s no extra overhead associated with some other solutions that need two separate pieces of software to achieve the same functionality.
How can LSCache speed-up my website?
If your website uses code, such as PHP, Ruby, Python, NodeJS etc. to generate the output your users see then it takes time for that code to run, perform queries on data in a database such as MySQL etc. which slows down how fast your web pages load. With LSCache the output from the code is saved (cached) and is used again if another request is made for the same page, this has two main benefits:
It means pages load faster for your visitors if they are loaded from the cache
It means you’re using less of your CPU and memory resources for each page viewed, as you’re not repeatedly running your code
What about personalised content?
We’re glad you asked, as LSCache can deal with that as well in a number of ways:
Every user gets their own personal, private cache which speeds up their own browsing without affecting other visitors
You can mix and match the public (all visitors) and private caching for a single visitor, using only the private when you need to
You can make use of Edge Side Includes (ESI) to mark parts of your content e.g. shopping basket widget as private and the rest of the page as public
As you can see, it’s a very flexible and powerful solution.
How can I use LSCache on my website?
There are two main ways to use LSCache on your website and if you need to you can combine them both for increased flexibility and usability.
Via a plugin for your software
LiteSpeed develop plugins for several popular pieces of software, this allows you to use the features of LSCache quickly and easily without a needing a lot of technical knowledge. Currently there are plugins for:
As you can see that covers quite a lot of the most popular pieces of software for creating websites. We’ll be doing a deep dive in to each of them at a future time as the different plugins have different levels of functionality, so be sure to follow us on social media so you don’t miss any.
Via rewrite rules (.htaccess/mod_rewrite)
For power-users or those that need a bit more control than the LSCache plugins offer there’s the option to use Apache style rewrite rules in your .htaccess file or inside your virtual host configuration if you’re using Apache style configuration files.
As it’s using mod_rewrite for the rewrite rules you can access to the full breadth and depth of capabilities within mod_rewrite for attaching conditions and matching user request for content:
Want to cache your front page for 30s and all others for 5 minutes? Not a problem
Want to cache all pages in the public cache except those starting with /cart/? Not a problem
Want to exclude specific IP addresses from the cache? Not a problem
Want to exclude specific pages from any caching? Not a problem
Want to cache content for guests but not for logged in users? Not a problem
That’s just a sample of the power using rewrite rules gives you, and just like with the plugins we’ll be doing a deep dive in the future on how to use rewrite rules to control LSCache, so be sure to follow us on social media.
How much will LSCache cost me?
That all really depends on your hosting company, for our virtual hosting we don’t charge anything at all for you to make use of it as we use LiteSpeed Enterprise Server for all of our virtual hosting servers, other companies only offer LiteSpeed on specific packages.
If you want to make use of LSCache on your own dedicated or virtual/cloud server then you will need a license for LiteSpeed server – If your server is hosted with us, or we manage your server for you, then we can provide an appropriate license for you, as a LiteSpeed Partner.