Private vs Public Cache

Davo

New Member
#1
After reading the Wiki, I am still a little confused about when to use each one and why there are two caches in the first place. A typical website of ours will use WordPress and WooCommerce. We want them cached to speed them up primarily for anonymous website visitors and especially for Google page ranking purposes (speed factor). Could someone please address my initial assumptions:
  1. Our websites should typically ONLY require use of Public cache
  2. If members do log into our websites (eg: shopping members) they will still receive the same benefits from the Public cache and it will work as expected or it will not function correctly and these pages MUST be set to use Private cache (so we will be using two different caches on the same website)?
  3. Public cache cannot be set to Global so that it is on for all websites
  4. Private cache is really only suitable for forums and website apps such as Facebook, etc where visitors are primarily members
  5. Are there any good use-cases with REAL working code for caching a typical WordPress and WordPress/WooCommerce website? I ask this because much of the code that i am typically forming from the documentation is not working as expected. I'd just like to see an example that turned the public cache on, excluded pages that had "cart" in the URL and excluded pages that contained the following string "/?add-to-cart=" in the URL. Please note: we would like to avoid adding any code to our website pages (with exception of htaccess) or having to set any special cookies specifically for Litespeed.
FYI We're using LWS Enterprise (1CPU) over WHS/Cpanel...

Thankyou in advance
 

NiteWave

Administrator
#2
I just installed a bare wordpress 3.9.2 and tested cache function yesterday(for another trouble-shooting). here's the .htaccess
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
RewriteCond %{REQUEST_URI} !^(wp-admin|wp-login.php|wp-cron.php)
RewriteRule .* - [E=Cache-Control:max-age=300]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

# END WordPress
the cache policy is:
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

did simple tests and cache working as expected

>FYI We're using LWS Enterprise (1CPU) over WHS/Cpanel...
but cache is enabled only for 2-CPU(and above license). see
http://www.litespeedtech.com/products/litespeed-web-server/editions
 

Michael

Well-Known Member
Staff member
#3
Hi Davo,

You should give some consideration to the example rewrite rules Gary posted. Though they may not do exactly as you wish, they are a start. Gary is an expert on caching. I am not.

As to your questions, though, I can give some answers:

1. Public cache is far more effective. If used well, yes, it makes sense to have only public cache and no private cache. There are situations where they could possibly be used together, but it wouldn't necessarily add much benefit.
2. The difference between public and private cache has nothing to do with whether a user is logged in or not. Public cache is used by all viewers to a certain URI. Private cache is used only for the IP it was created for. It does not matter if that user is logged in or not. If you have private cache turned on for a page, Guest1 will get their cached copy of that page when they access it a second time. Guest2 will not get that copy. Neither will LoggedInUser1. But, if LoggedInUser1 visits the page twice, they will get their cached copy. Thus, private cache is safe for use on pages that other users should not see. It is not very efficient, though.
3. Public cache CAN be set to global, but it probably SHOULD NOT be. Caching all pages is not safe, as a user might get the cached version of another user's page. (Sorry if I was too harsh about that distinction. I realize that it may be a small difference, but I just want to be clear.)
4. Not true. Again, private cache has nothing to do with whether a user is logged in or not. With private cache, non-logged in users don't share either. Forums actually benefit greatly from public cache because a large part of forum traffic is guest users. If you differentiate logged in and guest users with, say, a cookie, you can make sure that all guest users share the public cache: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscache:vbseo
5. Commerce sites are difficult to use with cache, since the shopping cart typically appears on all pages and thus those pages cannot be cached publicly. This is where private cache comes in handy. We are working on ESI implementation for LSWS 5.0. This will allow you to partially cache pages so you can cache everything on the page except for the shopping cart. For now, you should check out our Magento rules: https://www.litespeedtech.com/support/wiki/doku.php/archive:lscache_magento

And please feel free to keep asking Gary's advice. Again, for hands on experience, he's the expert.

Cheers,

Michael
 

Davo

New Member
#4
Thanks very much for your advice guys. Never really got it working correctly but you're help was much appreciated. Had to revert back to #$!@i%h :)

Cheers
 
Top