Differences

This shows you the differences between two versions of the page.

Link to this comparison view

litespeed_wiki:cache:no-plugin-wordpress [2017/01/03 21:31]
Michael Alegre created
litespeed_wiki:cache:no-plugin-wordpress [2018/07/03 16:08] (current)
Lisa Clarke
Line 1: Line 1:
-====== LSCache + WordPress Configuration ====== +~~REDIRECT>​litespeed_wiki:​cache:​lscwp~~
- +
-**Note: This page describes an easy way to set up simple caching for WordPress installations. With the release of LiteSpeed Cache for WordPress, though, this solution is now deprecated. Click [[litespeed_wiki:​cache:​lscwp|here]] for the  LiteSpeed Cache for WordPress installation and configuration manual.** +
- +
-LSCache, similar to Varnish cache, is a simpler and more efficient page caching solution built-in to LiteSpeed Web Server. When used in conjunction with WordPress, the Internets leading content management system, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible with the ability to use rewrite rules to customize LSCache'​s behavior. +
- +
-Below are some recommended configurations to enable LSCache and get it working with your WordPress site(s). +
-===== Server Level Settings ===== +
- +
-From the LSWS WebAdmin Console navigate to **Server >> Cache**. +
- +
-Under **Cache Storage Settings**, set **Storage path** to the directory you want to use to store cached objects. +
- +
-For example: +
- +
-    Storage Path: /​tmp/​diskcache +
- +
-It is recommended that this directory be on a dedicated disk or disk array in RAID 0 configuration. +
- +
-For example: +
- +
-     mkdir /​tmp/​diskcache +
-     chown nobody:​nobody /​tmp/​diskcache +
-     chmod 700 /​tmp/​diskcache +
- +
- +
-Under **Cache Policy**, we recommend using the following settings: +
- +
-    Enable Cache:No +
-    Cache Request with Query String:​Yes ​        +
-    Cache Request with Cookie:​Yes +
-    Cache Response with Cookie:​Yes ​        +
-    Ignore Request Cache-Control:​Yes +
-    Ignore Response Cache-Control:​Yes +
-    Enable Private Cache: No +
- +
-**Note:** **Enable Cache** has been set to "​No"​ globally as caching will instead be enabled through the use of rewrite rules to control what pages will be cached and for how long. +
-===== Website Level Settings ===== +
- +
-In your .htaccess file, located in the document root of your website, add the following:​ +
- +
-  <​IfModule LiteSpeed>​ +
-  RewriteEngine on +
-  RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$ +
-  RewriteCond %{REQUEST_URI} !^/​(wp-admin|wp-login.php|wp-cron.php) +
-  RewriteCond %{HTTP_COOKIE} ​ !wordpress_logged_in_ +
-  RewriteRule .* - [E=Cache-Control:​max-age=120] +
-  </​IfModule>​ +
- +
-===== Discussion ===== +
-__**Setting the homepage to be cached for less time than other pages**__  +
-     +
-Example rewrite rule: +
-     +
-    <​IfModule LiteSpeed>​ +
-    RewriteEngine on +
-    RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$ +
-    RewriteCond %{REQUEST_URI} !^/​(wp-admin|wp-login.php|wp-cron.php) +
-    RewriteCond %{HTTP_COOKIE} ​ !wordpress_logged_in_ +
-    RewriteRule ^$ - [E=Cache-Control:​max-age=60,​S=1] ​    +
-    # The homepage will be cached for 60 seconds. +
-    RewriteRule .* - [E=Cache-Control:​max-age=600] ​        +
-    # All other pages will be cached for 600 seconds. +
-    </​IfModule>​ +
-     +
- +
-__**Caching two versions of each page (mobile and non-mobile)**__ +
- +
-Example rewrite rule: +
-     +
-  <​IfModule LiteSpeed>​ +
-  RewriteEngine on +
-  RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?​|phone|p(ixi|re)\/​|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR] +
-  RewriteRule .* - [E=Cache-Control:​vary=ismobile] +
-  RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$ +
-  RewriteCond %{REQUEST_URI} !^/​(wp-admin|wp-login.php|wp-cron.php) +
-  RewriteCond %{HTTP_COOKIE} ​ !wordpress_logged_in_ +
-  RewriteRule .* - [E=Cache-Control:​max-age=120] +
-  </​IfModule>​ +
- +
-**Important:​** Your rewrite rules must exactly match your backend'​s mobile detection. If these do not match, you may run into the issue where your rewrite rules think that a device is mobile while the backend does not and visa-versa. This can cause, for example, the desktop version of a page to be cached and flagged as the mobile version which will then be wrongly served to all mobile viewers. +
- +
-**Note:** "​E=Cache-Control:​vary=ismobile"​ is available as of LSWS version 5.0.7.+
  • Admin
  • Last modified: 2018/07/03 16:08
  • by Lisa Clarke