Tag: joomla tips

  • JT: Using ESI in Joomla with LSCache

    JT: Using ESI in Joomla with LSCache

    Joomla Tips: Using ESI in Joomla

    Welcome to another installment of Joomla Tips!
    Today’s topic is: Using ESI in Joomla

    Last week we discussed private cache for your Joomla site. Today we’re going to take that a step further and explore ESI, or “Edge Side Includes”. ESI takes the concepts of public cache and private cache, and combines them in a way that allows you to serve cached content flexibly and to more of your visitors, both logged out and logged in.

    Please note: ESI is not supported in OpenLiteSpeed. You must be using LiteSpeed Enterprise in order to take advantage of ESI functionality.

    What is ESI?

    ESI is a markup language. It allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. ESI lets you “punch holes” in a page, and then fill those holes with content that has different caching requirements than the rest of the page.

    For instance, ESI blocks can have different TTLs and be purged by events that are completely separate from the page they are on. Additionally, ESI blocks can contain private content even when the page they are on is publicly cached. This flexibility allows you to cache more of your site for more of your visitors. ESI is a an important aspect of any ecommerce caching strategy.

    How do ESI and Public/Private Cache Work Together?

    ESI allows you to disassemble a full page and treat the pieces differently from each other.

    LiteSpeed Web Server allows you to store content in either the public cache or a private cache.

    These two elements combine to give you something very powerful: a system that can break apart a page into public and private pieces, cache each piece appropriately, re-assemble the full-page content from the relevant caches, and then serve it to a user without ever hitting the PHP backend.

    That is pretty amazing!

    Using ESI in Joomla: Punched holes in paper

    Examples

    Let’s look at a few common scenarios where ESI is helpful.

    Example #1: The Login Module

    Let’s say your site has a login module on every page. You are logged in, and you visit your site’s home page, which is in the public cache.

    Without ESI: Your request must invoke PHP, because the login module contains private content, and as such this page (and every other page on your site, for that matter) cannot be served to you from public cache.

    With ESI: Most of this page is served to you from the public cache, but the login module is served to you from your private cache. There is no need to invoke PHP.

    Other Thoughts: Technically in this scenario, you could skip ESI and use logged-in caching for every page, but private cache storage adds up, particularly if you have a busy site, or a lot of pages on your site. Using ESI here means that the only thing you need to store in private cache for each user is the contents of a single module.

    Example #2: The Latest Articles Module

    Let’s say you have a large site with mostly static content that rarely changes. The “Latest Articles” module appears on each page.

    Without ESI: Every time a new article is published, every single page in the site must be purged so that the module displays up-to-date data. Re-populating the entire cache requires a crawler to run, or visitors to hit all of the pages of the site.

    With ESI: All of the pages in the site can remain cached with a nice long TTL, while the Latest Article module is the only thing that needs to be purged. Re-populating that one bit of the cache requires just one visitor to request any page one time.

    Other Thoughts: Using an ESI widget for this allows us to keep most pages in cache for a long time, while letting the module change as often as it needs to. If we weren’t using ESI for this, we’d be putting a lot of unnecessary load on the server, and increasing the chances that visitors to the site would encounter uncached content.

    Enabling and Configuring ESI

    When you enable ESI, you allow holes to be punched for content that will either be privately-cached, publicly-cached with its own TTL, or not cached at all.

    While leaving an ESI block uncached is an option, it is not recommended. An uncached module will need to invoke PHP each time that it is requested. PHP uses a lot of resources and slows down your page considerably. If you can avoid hitting the PHP backend, you should.

    Using ESI in Joomla: Advanced configuration screen

    To enable ESI, navigate to System > Global Configuration > LiteSpeed Cache and click the Advanced tab. Verify that ESI Feature Enabled is set to Enabled. It should be on by default.

    You can also set Render Login Module as ESI to Enabled here, although we are going to take care of that in the LiteSpeed Cache Settings (ESI Module Settings) screen below.

    Rendering Modules as ESI

    Any module can be an ESI block if you want it to be. Modules are perfectly-suited to it. They are already self-contained bits of code. Navigate to Components > LiteSpeed Cache.

    Using ESI in Joomla: Module settings screen before

    Select the modules that you would like to render as ESI blocks. The following types of modules are good candidates for ESI:

    • Any module that displays personalized information
    • Any module that displays something different for logged in and logged out users
    • Modules whose content changes very frequently compared to the rest of the site

    In this example, we’ve chosen the Login Form and User Menu, but you can choose any modules that make sense for your particular installation.

    Press the Render Modules as ESI button.

    Using ESI in Joomla: Module settings screen after

    The display will change to show only ESI Modules. At this point, you can click on a module name to configure the ESI settings for that module, like so:

    Using ESI in Joomla: ESI Module cache settings

    The important fields here are ESI Module Cache Type and ESI Module Cache Timeout, and how you set them depends entirely on the function of the module.

    Let’s look at the two modules we are setting up. We’re using ESI with them for two completely different reasons, and so we will configure them differently. These are the same two modules from our previous examples.

    Using ESI for Frequently Changing Content

    We can use an ESI module to display frequently-changing content on pages that rarely change.

    The “Latest Articles” module always contains public content, so we can set the ESI Module Cache Type to Public. We want to use ESI for this module because we have an active site with new content being added every hour or so. We set ESI Module Cache Timeout to ‘60’ minutes, so that the module stays up to date with the more recently published articles.

    Now we are free to set the site’s Public Cache TTL to something more appropriate for a site with rarely-changing pages, like a week (or 10080 minutes).

    Using ESI for Private Content on a Public Page

    We can use an ESI module to punch a hole for private information on a public page.

    The “Login Form” module says one thing when the user is logged out, but contains personalized content when the user is logged in. For that reason, we should set the ESI Module Cache Type to Private. We can leave the other settings at their defaults.

    Then, when a user logs in, there is no need to serve them everything from private cache. We can serve all of the pages from public cache, and simply punch holes for the private content stored in the “Login Form” module.

    Conclusion

    So what do you think? Would you like to give ESI a try on your site?

    ESI allows you the flexibility to cache more of your site in a variety of complex situations. With pages that mix-and-match private/public cache or differing TTLs, you can serve cached content to a larger percentage of your users, and keep everything running quickly and smoothly.

    P.S. Want to know more technical details about ESI? Check out the official specs.

    Disclaimer: The information contained in this post is accurate for LSCJoomla v1.2.0 [release log]. If you are using a newer version of the plugin, some details may have changed. Please refer to our wiki for the latest!

    Have some of your own ideas for future Joomla Tips topics? Leave us a comment!

    While you’re waiting for the next installment, here are a few things you can do:

  • JT: Caching Logged-in Users in Joomla

    JT: Caching Logged-in Users in Joomla

    Joomla Tips: Caching Logged-in Users in Joomla

    Welcome to another installment of Joomla Tips!
    Today’s topic is: Caching for Logged-In Users in Joomla

    In our first issue of Joomla Tips, we introduced the LiteSpeed Cache for Joomla plugin, and explained how to easily configure the basic settings. These settings are perfectly sufficient for Joomla sites where there is no ecommerce, and the majority of visitors do not log in to the site.

    In such simple installations, a single cached copy of each page is sufficient, because all visitors will be seeing the same content anyway. But what about sites where there is a significant population of visitors with user accounts? Under the default configuration, logged-in users are not served from cache. This behavior is easy enough to change, and today we’ll show you how.

    Enabling Logged-in Caching

    In order for your logged-in users to also experience the same acceleration benefits as your logged-out visitors, you need to be able to serve them pages from the cache.

    Caching Logged-in Users in Joomla: Logged-in Users Configuration Screen

    Navigate to System > Global Configuration > LiteSpeed Cache and click the Logged-in Users tab. Set Show Cache Content for Logged-in Users to Enabled.

    If you save the settings here and purge the existing cache, you will indeed be serving all future logged-in visitors from cache. Just be aware that logged-in users will be getting the same publicly cached copies of pages as the non-logged-in users are getting. This may or may not be appropriate for your needs.

    If you need to cache individualized content for logged-in users, there are two ways of doing so:

    • Full pages served from private cache
    • ESI assembled pages where it’s mostly public, but holes are punched for private content

    Private Full Page Caching

    On the same configuration screen where you enabled cache for logged-in users, you can also enable private cache. Set Separate Cache Copy for Logged-in Users to Enabled, save the settings, and purge the cache.

    Once this setting is enabled, an individualized copy of any visited page is stored in private cache for each logged-in user that requests it. So, if there are 10 logged-in users, and 20 logged-out users looking at the home page, then there are 10 cached copies of the home page stored in private cache (an individualized copy for each logged-in user), and 1 copy of the home page stored in public cache for the logged-out users to share.

    Caching Logged-in Users in Joomla: Princeton Historical Society Please Come In

    How do you know whether to enable or disable this setting? Enable it when you have personalized content on a page, like a special blog post, or a shopping cart. You can safely leave this setting disabled if your logged in users don’t see any personalized content on the page, or if all personalized content appears within ESI modules.

    ESI

    With ESI (aka Edge Side Includes), you “punch holes” for private content in publicly cached pages. This makes sense if you have a site where nearly all of the content is public, but there is private content appearing within some of the modules. It’s also highly recommended for ecommerce sites.

    There is a lot we can say about ESI, so we’ll save it for its own post.

    Summary

    You can use the settings on the Logged-in Users configuration page to enable caching for logged-in users. For a site without personalized content, you can serve to them from public cache. And for a site where logged-in users see different content than those that are not logged in, you have the ability to serve to them from private cache.

    Next week we’ll talk about ESI, and how those settings can help you to be even more flexible, and allow you to accurately cache your entire site for all of your visitors!


    Disclaimer: The information contained in this post is accurate for LSCJoomla v1.2.0 [release log]. If you are using a newer version of the plugin, some details may have changed. Please refer to our wiki for the latest!

    Have some of your own ideas for future Joomla Tips topics? Leave us a comment!

    While you’re waiting for the next installment, here are a few things you can do:

  • JT: The Beginner’s Guide to LSCache for Joomla

    JT: The Beginner’s Guide to LSCache for Joomla

    Joomla Tips: Beginner's Guide to LiteSpeed Cache for Joomla

    Welcome to the first installment of LiteSpeed’s Joomla Tips!
    Today we are sharing a Beginner’s Guide to LiteSpeed Cache for Joomla!

    If your Joomla site is powered by LiteSpeed Web Server, you have a very powerful new tool at your disposal: the LiteSpeed Cache plugin for Joomla. LSCache is a high-performance, open source, user friendly cache plugin, and you don’t have to be a site optimization expert to use it.

    How it Works

    Joomla sites consist of dynamic pages that are built with PHP. The pages of a Joomla site don’t exist anywhere in the file system; they are constructed on demand through PHP, and then served to the visitor as HTML. This can be a resource-heavy process, and the LiteSpeed Cache for Joomla plugin is one way of dealing with it.

    When Joomla dynamically generates the static HTML page, LSCache communicates with LiteSpeed Web Server to store a copy of it. Once the static copy exists in the cache, then that copy can be served to future visitors, eliminating the expensive Joomla PHP process for all but the first visitor to request the page.

    When your site is cached, it requires much less involvement from the Joomla backend, which translates into a faster site and a better experience for your site’s visitors.

    Enable the Plugin

    We’re going to assume you (or your hosting provider) have already installed the plugin and configured LSCache at the server or virtual host level. If you need instructions for that, you can see our wiki. Don’t forget to deactivate all other full-page cache plugins, including “System – Page Cache” and “JotCache,” as well.

    NOTE: You can still use other types of cache (like object cache), but only one page cache can be used at a time, so you’ll need to disable the others, if you want to use LSCache.

    From your Joomla Administrator menu, navigate to Extensions > Plugins. If you have a lot of plugins listed, type LiteSpeed into the search box to bring up the LiteSpeed Cache Plugin.

    Beginner's Guide to LiteSpeed Cache for Joomla: Enable the Plugin

    Look for the green check mark next to the plugin name. This indicates that the plugin is installed and enabled. If you see a red X instead, click the red X to enable the plugin. Once you’ve done that, the green check mark should appear, and you are good to go.

    Configure the Plugin

    Beginner's Guide to LiteSpeed Cache for Joomla: Cat in a Box

    LiteSpeed Cache works with most Joomla setups right out of the box. “Out of the box,” of course, is a figure of speech. Software rarely comes in a box anymore, which is great for the environment, but maybe not so great for your cat, who just loves cardboard boxes…

    The point, of course, is that LSCache for Joomla usually just works. It can often be enabled and ignored. There’s usually no need to play around with the settings, unless your site has atypical needs.

    Just the same, let’s go over some of those settings, so that you can use them if you want to.

    Navigate to System > Global Configuration > LiteSpeed Cache to access the plugin’s settings. The first tab is for Basic settings.

    The Basic Tab

    Beginner's Guide to LiteSpeed Cache for Joomla: The Basic Tab

    Here is where you enable or disable the caching functionality of the plugin (not to be confused with enabling the plugin itself, which we did earlier), and set a few parameters for the way it should behave.

    Enable LiteSpeed Cache

    By default, caching is already enabled once you install and enable the plugin. If you need to stop caching your site for whatever reason, you can press Disable to turn it off. Simply press Enable to get it back up and running again.

    Public Cache TTL

    “TTL” stands for Time to Live, and it refers to the length of time a web page is valid within the cache. The default is 2000 minutes, but if you have a site that updates frequently, you might want to make that number smaller. Similarly, if you have a site that is fairly static and rarely changes, you can make that number much larger.

    Note: LSCache’s “smart purge” technology allows you to confidently set a high TTL, knowing that if content changes during that time, the cache will automatically be purged for any pages that are relevant to that change. We’ll explore that concept in more detail in a future Joomla Tips article.

    Purge All on Plugin Update

    If you are concerned that plugin updates are going to change some of the pages of your site (thereby causing the cached copies to become outdated), then you should enable this setting. It’s disabled by default, because usually plugin updates have minimal effect (if any) on the displayed content.

    Purge All on Language Update

    This is similar to the previous setting, except it refers to language updates, and it is enabled by default.

    Logging Level

    You can leave logging off in most cases. It’s handy to turn on logging when you are trying to diagnose a problem. If you’ve contacted our support team for help with an issue, chances are we’ll ask you to turn on logging and we’ll also tell you which level would be appropriate.

    Any time you turn on logging, it should be temporary, as logs can eat up disk space pretty quickly.

    All Other Tabs

    The other tabs may be ignored, unless you are feeling experimental, or you are using your Joomla installation for ecommerce. We’ll discuss them in detail in future issues of Joomla Tips. For now, here’s a short overview explaining the purpose of each tab.

    Exclude Rules

    Beginner's Guide to LiteSpeed Cache for Joomla: Exclude Rules

    This tab allows you to specify Joomla components, menus, and URLs that should not be cached.

    Advanced

    Beginner's Guide to LiteSpeed Cache for Joomla: Advanced Tab

    You can set up ESI here (a must if you are trying to cache an ecommerce site), give yourself the ability to clear the cache from a secure link outside of Admin, set a different TTL for the homepage, and set up LSCache to save separate views for mobile and desktop.

    Logged-in Users

    Beginner's Guide to LiteSpeed Cache for Joomla: Logged in Users Tab

    These settings pertain to caching for users who are logged in. By default caching for logged-in users is disabled.

    Recache

    Beginner's Guide to LiteSpeed Cache for Joomla: Recache Tab

    Usually, when a page is purged from the cache, it remains uncached until a visitor comes along and requests the page. With Auto Recache enabled, LiteSpeed will automatically re-cache those purged pages, which means that your site’s visitors will have a lower chance of ever encountering uncached content.

    Permissions

    This is your standard Joomla permissions page, and every setting defaults to Inherited.

    Support

    You can refer to this page if you need support. It includes some handy links.

    Manual Purge

    In a perfect world, you could enable caching and never look at the plugin again. In the real world, though, things happen, and you might need to manually purge the cache now and then. Here’s how:

    Beginner's Guide to LiteSpeed Cache for Joomla: Manual Purge

    Navigate to Components > LiteSpeed Cache, and press the green Purge All LiteSpeed Cache button. All of the entries currently stored in the cache will be cleared.

    If you want to re-populate the cache after that, you can do so via the Rebuild All LiteSpeed Cache button.

    And that is all you need to know to use LSCache for Joomla successfully as a beginner! There may come a time when you would like to explore ESI, or Logged-in cache (both very powerful features, especially for ecommerce). We’ll be talking all about those options in a future Joomla Tips, so stay tuned!

    Disclaimer: The information contained in this post is accurate for LSCJoomla v1.2.0. If you are using a newer version of the plugin, some details may have changed. Please refer to our wiki for the latest!

    Have some of your own ideas for future Joomla Tips topics? Leave us a comment!

    While you’re waiting for the next installment, here are a few things you can do: