Cached pages, Wordpress and the user toolbar

Discussion in 'LiteSpeed Cache General' started by NewMedia, Nov 13, 2015.

  1. NewMedia

    NewMedia New Member

    Hi There,

    We are using the following in .htaccess to cache pages for our WordPress sites:
    # Litespeed Cache Control
    <IfModule LiteSpeed>
        CacheEnable public
        RewriteEngine On
        RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
        RewriteCond %{HTTP_HOST} ^ [NC]
        RewriteCond %{REQUEST_URI} !wp-admin|wp-login.php|wp-cron.php|bla|otherpages|etc
        RewriteRule .* - [E=Cache-Control:max-age=120]
    So... If a user is logged into wp-admin, and has the "Show Toolbar" option ticked (default option) and browses the front end site, litespeed will cache that page - along with the toolbar! A non-logged in user comes along and litespeed serves the page from cache.. boom.

    As you could imagine this was a serious WTF moment! was PHP caching sessions for some reason? bla bla.. it was quite funny when we worked it out. :)

    Anyway.. we are at a blank - any ideas on how to stop this happening?

    Note: As a work around, we have added "add_filter('show_admin_bar', '__return_false');" to the functions.php file in the theme, this disables the toolbar for all users no matter the setting in the admin.

    Cheers! TGIF here in NZ!

    Last edited by a moderator: Jul 3, 2018
  2. NiteWave

    NiteWave Administrator

  3. bbnz

    bbnz New Member

    Was this ever solved? New member here, long time Litespeed user without cache option. I don't run Wordpress, however I have a social platform where users can be logged in on the home page and interact with the site. In initial testing I run into this same (and as expected) problem of having username info cached in the menu bar. I did some basic exclusions of php class files that contain this information, however I think it it may be more to do with Session Cookies for username values that I need to look at, as this session is called all throughout the code to give users that personal experience that we all become familiar with on Facebook, Linkedin etc.

    My host company has enabled the LScache for me and performed basic configuration, although as they are more Nginx and HHVM type providers this is a new area for them to test in.

    Are there other Litespeed users that don't use Wordpress, Magento, Vbulletin, Drupal, Joomla etc but have had luck in running LSCache in a dynamic social type of platform?
  4. Lauren

    Lauren LiteSpeed Staff Staff Member

    If it's your own custom developed platform, you can change your code to use ESI. Basically all user info content will be in private cache, the rest page is in public cache. We will have some documentation out later, but not available at the moment. The page can be served from cache by assembling private & public cache, similar to our LiteMage implementation.

    If you want us to do it for you, we can discuss offline for a custom project, but that will be time spent x our hourly rate.
  5. bbnz

    bbnz New Member

    Hi Lauren. Thanks for that reply. I didn't actually know what ESI was, so have done a bit of research and see how to apply ESI tags accordingly. I will give it a go and update here with any results I get. It might help other website owners who have custom platforms and are interested in using LS Cache. Thanks!
  6. bennieblanco

    bennieblanco Active Member

    this just happened to me with these directives
    <IfModule LiteSpeed>
    CacheEnable public /
    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
    RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login.php|wp-cron.php)
    RewriteRule .* - [E=Cache-Control:max-age=120]
    had to rename lscache folder to kill the pages since visitors were able to
    see admin bar and super admin logedin

    and immediately disabled lscache, charging a license for this hiccup is a joke
    Last edited by a moderator: Jul 3, 2018
  7. mistwang

    mistwang LiteSpeed Staff

  8. bennieblanco

    bennieblanco Active Member

    Your plugin is horrible , is caching everything is not even funny. It killed access to amember, caching what is not supposed to
    caching admin bars, hiding plugins/themes updates, I mean is not even funny , this is just a huge fail.
  9. mistwang

    mistwang LiteSpeed Staff

    You are following out-dated guide.
    The rewrite rule you tried is not from our cache plugin solution. We do not recommend using it now. Can you pointing me where you get that? We need to take it down.
    You do not have the plugin installed yet. It is much smarter as it hooks into WP internal logic.
  10. bennieblanco

    bennieblanco Active Member

    Bud , I installed the plugin last night and it simply swallowed everything
    we were locked out of amember connected to wp , it cached everything I mentioned
    than we disabled it and when the plugin is inactive the page load TTFB spiked from 0.600ms to 2sec
    it is horrible I tell you.

    The directives we found here o forums
  11. bennieblanco

    bennieblanco Active Member

    Il open a new thread
  12. Pong

    Pong Well-Known Member Staff Member

    You placed the wrong directive there.
    the following directive should not be used.
    CacheEnable public /
    Which enable cache for everything and leads to all your errors mentioned.

    Our WordPress plugin does not cache admin at all. You should not miss your own rewirite rule with our wordpress plugin. Remove all your rwrite ruels and then install and enable cache plugin, the plugin will add proper rules for you automatically.
    Last edited: Jul 3, 2018
  13. bennieblanco

    bennieblanco Active Member

Share This Page