Run Litespeed Cache with Concrete5

Caching systems don't always play ball when you are editing your site because caching is all about serving up saved "snapshots" of a site, whereas editing is all about changing stuff. Litespeed's cache is no different, so for Concrete5 we needed a solution for when we are editing the site. Although tested, please follow this guide at your own risk, we accept no responsibility for issues caused by following and using this information.

Although tested, please follow this guide at your own risk, we accept no responsibility for issues caused by following and using this information.

Easy fix for Dev Sites and Sites with Admin Directory

It's easy to disable Litespeed's cache for for dev sites and sites with admin directories because you can just add some simple rules to .htaccess:

 <IfModule LiteSpeed> CacheDisable public / CacheDisable private / </IfModule> 

Or even:

 RewriteRule (.*) - [E=Cache-Control:no-cache] 

But with Concrete5 there is no admin directory, so we can only work with the same .htaccess as the live site.

Access Through a Subdomain

We had the idea to access the site through a subdomain. By pointing the subdomain at our servers IP and setting up the subdomain in cPanel resolving to /public_html, we can view our site through the subdomain and the url won't change. We would just need to disable any rules that try and force non-www urls to the www version so that our admin.madesimplemedia.co.uk doesn't immediately go to www.madesimplemedia.co.uk.

subdomain-in-cpanel.jpg

So now we needed some rules to just set the Litespeed cache on the live site, not our new admin subdomain. Massive thanks to NiteWave on the Litespeed forum for providing the code:

This was added to our .htaccess file on the live site. So now we have nice fast cache on live but we can edit the site on the admin subdomain without the the cache interfering.

Notice the 86400, that is the number of seconds in a day. So we are saying we want to cache everything for a day.

But wait, there is more to do yet...

SEO Implications

Now we have our website live on www.madesimplemedia.co.uk and admin.madesimplemedia.co.uk. But for SEO this is bad, we now have duplicate content on two domains.

So to deal with this we need to:

  1. Prevent Google indexing admin.madesimplemedia.co.uk but
  2. Make sure our live site's SEO is not compromised.

So we can't just "disallow all" with robots.txt in admin.madesimplemedia.co.uk because that robots.txt file is also used by the live site because the content of both sites is the same!

But there is the robots meta tag, so we could use PHP to get the current url and if it contains "admin" we can write out the noindex attribute:

 <?php $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; if(strpos($url, 'admin')) { echo '<meta name="robots" content="noindex,nofollow">'; } ?>  

This tag will only be written on pages on the admin.madesimplemedia.co.uk site, so Google will still index our live site as normal.

An Additional SEO Measure...

An additional measure is to add the admin.madesimplemedia.co.uk site to Google Search Console (formally Webmaster Tools) and hiding the site.

We needed to add the site and verify it, then go to Remove URL's and Temporarily hide and add a /.

This should hide the whole site:

temp-hide.jpg

Stop admin Subdomain Redirecting to Main Site

The only other issue we had is that we were forcing non-www urls to go to www.madesimplemedia.co.uk.
So we just changed our redirect to be more specific and only redirect the mail domain to the www version:

 RewriteCond %{HTTP_HOST} ^madesimplemedia.co.uk [NC] RewriteRule ^(.*)$ <a href="https://www.madesimplemedia.co.uk/https://www.madesimplemedia.co.uk/$1">https://www.madesimplemedia.co.uk/$1</a> [L,R=301]  

Hope that was helpful and helps you get your super fast new Litespeed server running great with Concrete5!

Who are we?

We are a digital agency specialising in Web Design, Development, Concrete5 and digital marketing, based in London & West Sussex.

We make digital simple. Our purpose is to simplify your frustrations in digital and solve the challenges you face to help make you more money and progressively grow your business or organisation.

Tell me more

Keep up to date

June special offer...

FREE hosting in year one

We'll give you FREE hosting when you buy a website from us. The hosting includes full 24x7 UK support, FREE SSL cert, FREE domain, daily backups and is optimised for high levels of speed and security. Worth up to £480 a year!

Tell me more
Call us