• Call Us : 1-323-486-1121

How to Enable Caching on Turbo Web Hosting

In this article, you will learn how to enable caching on Turbo Web Hosting.

 

Enabling Caching  

On Turbo Boost and Turbo Max Web Hosting accounts caching is usually disabled by default. To enable caching for your account, you use directives in an .htaccess file. The directives provided give you the ability to control which types of content the Turbo Boost or Turbo Max Web Hosting server caches, and for how long. You have to create the .htaccess file in the base folder for the application that you want to cache.

From the configuration provided below you can see how to enable caching on a Turbo Boost or Turbo Max Web Hosting account:

<IfModule LiteSpeed>

    CacheEnable public

    RewriteEngine On

    RewriteCond %{REQUEST_METHOD} ^GET|HEAD$

    RewriteCond %{HTTP_HOST} ^example.com [NC]

    RewriteCond %{REQUEST_URI} !login|admin|register|post|cron

    RewriteCond %{QUERY_STRING} !nocache

    RewriteRule .* - [E=Cache-Control:max-age=300]

</IfModule>

 

It is a good idea to go through the configuration line by line, so you learn more about it:

  • The first line checks to make sure the Turbo Boost or Turbo Max Web Hosting server is running LiteSpeed.
  • The second line enables the public cache. Turbo Boost and Turbo Max Web Hosting servers have a public and private cache. Usually, you want to use the public cache, which caches content for multiple clients. The private cache is used to cache content for a single client (for example, personal information for an authorized user).
  • The third line turns on URL rewrite functionality. Turbo Boost and Turbo Max Web Hosting servers use rewrite conditions and rules to control caching behavior.
  • The fourth, fifth, and sixth lines use RewriteCond directives to specify what should and should not be cached. The REQUEST_METHOD condition instructs the server to cache GET and HEAD requests, but not POST requests. The REQUEST_URI condition, because it begins with an exclamation mark (!), instructs the server to not cache any page whose URL contains login, admin, register, post, or cron.
  • 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.
  • The RewriteRule directive actually sets the cache duration. In this example, pages are cached for five minutes (300 seconds).

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Differences Between Turbo Web Hosting Servers and Drive Web Hosting Servers

From a user perspective, TBC-Hosting's Turbo Boost and Turbo Max Web Hosting servers behave...