Enabling caching for Joomla on Turbo servers
Learn how to enable caching for Joomla on a Turbo server. This article covers two methods: using a caching plugin, and enabling caching manually in an .htaccess file.
This article describes how to enable caching for Joomla on a Turbo server.
Note
The information in this article is specific to Joomla. For general information about caching on Turbo accounts, please see this article.
Caching for Joomla does not work correctly if you have a shopping cart enabled.
Enabling caching for Joomla
There are two ways to enable caching for Joomla on a Turbo server:
-
Use a caching plugin: This method only works for Joomla 3.0 and newer versions.
-
Enable caching manually: This method works for all Joomla versions, but requires more configuration than the plugin method.
Method #1: Use a caching plugin
To enable caching for Joomla on a Turbo server using a plugin, follow these steps:
- Download the LiteSpeed Cache plugin file:
-
Use your web browser to go to https://www.litespeedtech.com/products/cache-plugins/joomla-acceleration/download.
-
Download the .zip file to your local computer.
-
Log in to Joomla as the administrator.
-
On the top menu bar, click Extensions, click Manage, and then click Install.
-
Click the Upload Package File tab.
-
Under Upload & Install Joomla Extension, click Or browse for file, locate the .zip file you downloaded in step 4, and then click Open. Joomla installs the plugin.
-
To verify the plugin is installed, on the top menu bar, click Extensions, and then click Plugins. LiteSpeed Cache Plugin should appear in the list of installed plugins with a green checkmark next to it.
Tip
To verify that caching is working correctly on your account, you can examine the raw HTTP headers sent between the browser and web server. (To do this, use a browser plugin that displays the raw headers such as Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome.) When content is served from the cache, the server adds the following line to the HTTP response header:
X-LiteSpeed-Cache: hit
If you do not see this line in the HTTP response header from the server, then the content was not served from the cache.
Method #2: Enable caching manually
To enable caching for Joomla on a Turbo server manually, follow these steps:
-
In the directory where you installed Joomla, open the .htaccess file in a text editor. You can use one of the text editors in cPanel, or you can log in to your account using SSH and use a command-line editor.
Note
If the .htaccess file does not exist, create it.
-
Copy the following text and paste it at the top of the .htaccess file:
<IfModule LiteSpeed>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{HTTP_COOKIE} !loginuser
RewriteCond %{ORG_REQ_URI} !^/index.php$
RewriteCond %{ORG_REQ_URI} !administrator
RewriteCond %{ORG_REQ_URI} (\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteCond %{QUERY_STRING}!nocache
RewriteRule .* - [E=Cache-Control:max-age=300]
</IfModule>
Important
These caching configuration directives must be at the top of the .htaccess file.
If your Joomla site uses a custom administration URL, use that instead of administrator . For example, if your Joomla login URL were http://example.com/secretadmin, you would use the following line:
RewriteCond %{ORG_REQ_URI} !secretadmin
You only need to include the HTTP_HOST configuration line if you host more than one domain in the public_html directory (such as your primary domain and a subdomain). Replace example.com with the domain name for which you want to enable caching.
The QUERY_STRING configuration line enables you to see the non-cached version of any page by adding nocache to a query string in the URL. For example, to view the non-cached version of http://example.com/mypage, you could add ?any_field=any_value&nocache to the end of the URL.
- Save your changes to the .htaccess file. Caching is now enabled.
Tip
To verify that caching is working correctly on your account, you can examine the raw HTTP headers sent between the browser and web server. (To do this, use a browser plugin that displays the raw headers such as Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome.) When content is served from the cache, the server adds the following line to the HTTP response header:
X-LiteSpeed-Cache: hit
If you do not see this line in the HTTP response header from the server, then the content was not served from the cache.
Caching and static content
Turbo accounts do not cache static content, such as audio and image files, on the web server. This type of content is cached by client web browsers instead. However, you can specify how long web browsers should cache your static content by using the ExpiresByType directive in the .htaccess file. For example, the following lines instruct web browsers to cache MP3 files for one year (31557600 seconds) and GIF files for 30 days (2592000 seconds):
ExpiresByType audio/mp3 A31557600
ExpiresByType image/gif A2592000
For more information about the ExpiresByType directive, please visit https://httpd.apache.org/docs/2.4/mod/mod_expires.html#ExpiresByType.
More Information
For detailed information about LiteSpeed caching, please visit http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:litespeed:cache.
Related Articles
Updated 3 days ago