Integrate LiteSpeed Cache for Xenforo 2 in XenVn add-on

Integrate LiteSpeed Cache for Xenforo 2 in XenVn add-on

Integrate-LiteSpeed-Cache-for-Xenforo-2.jpg


LiteSpeed Cache Plugin for XenForo 2 (LSCXF2) is a PHP-based plugin that communicates with your installation of LiteSpeed Web Server(LSWS) and its built-in page cache, LSCache. Because LSCache is built directly into LSWS, overhead is significantly reduced and caching can be done more efficiently than with other PHP-based caches.

XenVn has integrated LiteSpeed Cache support for better performance and security.

Features:

  • Automatic guest page caching
  • Automatic CSS caching
  • Automatic image attachment caching
  • Automatic sitemap, rss caching
  • Automatically update CSRF token
  • Automatically disable caching for ajax requests and important urls
Enable this feature at: XenVn Setting -> Extra-> Mod View -> Integrate LiteSpeed Cache
To enable cache for image attachments. You must enable: XenVn Setting -> Attachments -> View All Image Attachments.

Configuration:
Configuration for LiteSpeed Cache is handled at the .htaccess level. There is no admin screen.
The configuration code for the .htaccess file is included in the XenVn add-on.

Here is an example of the basic configuration. Edit the .htaccess file in the XenForo root directory and add the code shown below to the top of the file:
Code:
# LiteSpeed XenForo cache
<IfModule litespeed>
    CacheLookup public on
    RewriteEngine On
    # cache
    RewriteCond %{HTTP_COOKIE} !(xf_lscxf_logged_in|xf_user|xf_session_admin) [NC]
    RewriteCond %{REQUEST_URI} !/install/ [NC]
    RewriteRule .* - [E=Cache-Control:max-age=360,E="cache-vary:xf_style_id,xf_language_id"]
    # no cache
    RewriteCond %{HTTP_COOKIE} (xf_lscxf_logged_in|xf_user|xf_session_admin) [NC]
    RewriteRule .* - [E=Cache-Control:vary=loggedin,E=Cache-Control:no-cache]
</IfModule>


OpenLiteSpeed Web Server.png


OpenLiteSpeed is the Open Source edition of LiteSpeed Web Server Enterprise.

Both servers are actively developed and maintained by the same team, and are held to the same high-quality coding standard.
OpenLiteSpeed contains all of the essential features found in LiteSpeed Enterprise, and represents our commitment to support the Open Source community.
OpenLiteSpeed combines speed, security, scalability, optimization and simplicity in one friendly open-source package.

Event-Driven Architecture
Event driven processes, less overhead, and enormous scalability. Keep your existing hardware.

Understands Apache Rewrite Rules
OpenLiteSpeed is mod_rewrite compatible, with no new syntax to learn. Continue to use your existing rewrite rules.

Friendly Admin Interfaces
OLS comes with a built-in WebAdmin GUI. Control panel support is available with CyberPanel.

Built for Speed and Security
Features Anti-DDoS connection and bandwidth throttling, ModSecurity v3 integration, and more.

Intelligent Cache Acceleration
Built-in full-page cache module is highly-customizable and efficient for an exceptional user experience.

PageSpeed Optimization
Automatically implement Google’s PageSpeed optimization system with the mod_pagespeed module.

PHP LiteSpeed SAPI
Native SAPI for PHP allows external applications written in PHP to run up to 50% faster.

One-Click Installation
Install OpenLiteSpeed, MariaDB and WordPress on various operating systems with just one click.


LSCache OpenLiteSpeed.png


What is LSCache?
LiteSpeed Cache (also called LSCache) is LiteSpeed's more efficient and highly customizable answer to Apache mod_cache and Varnish.

LSCache is built from the ground up and integrated into all LiteSpeed server products. It can:
  • dramatically speed up dynamic website content (like PHP pages)
  • provide more efficient handling of static content (like images)
  • reduce server load
Understanding Caching
If you are new to website caching, allow us to demystify a few basic concepts.

What is Caching?
Generally speaking, a cache is a mechanism for storing data in such a way that it is easier or faster to retrieve than the original source.

Web application sites consist of dynamic pages that are built with PHP or some other method. The pages of these sites don’t exist anywhere in the file system; they are constructed on-demand by the web app, and then served to the visitor as HTML. Generating these dynamic pages can be resource-intensive and slow.

There are actually several types of caches. LSCache is a "page cache." A page cache's job is to take this dynamically generated web page, and store it as a static HTML snapshot. That way, the next time the page is requested by a visitor, the snapshot can be served immediately. Serving a snapshot is much faster and uses far fewer resources than generating the page dynamically does.

How does LSCache Work?
Imagine you have an uncached page.

A visitor requests that page, and a few things happen:
  • LiteSpeed looks for the page among its stored cache objects and does not find it
  • LiteSpeed returns a "cache miss"
  • The web app dynamically generates a static HTML page while the visitor waits
  • LiteSpeed serves the static HTML page to the visitor
  • LiteSpeed stores the static HTML page as a cache object for later use
A few minutes later, another visitor requests that same page. Here's what happens:
  • LiteSpeed looks for the page among its stored cache objects and finds it
  • LiteSpeed returns a "cache hit"
  • LiteSpeed immediately serves the static HTML page to the visitor
Notice how the inefficient web app is not in the picture at all once the page has been cached? From this point on, until the cache object expires, any visitors who request that page will not have to wait around for the web app.

You can see why caching is good for your visitors, and good for your server load!

Why Use a Plugin?
The LiteSpeed Cache Engine can be controlled through rewrite rules in the .htaccess of a web app's document root. So what do you gain by using an LSCache plugin?

An LSCache plugin bridges the knowledge gap between a web app and the Cache Engine.

Put another way: web apps have rules about what content may be cached, for how long it may be cached, and what events would cause a cache object to become stale. LSCache plugins are a way of communicating these web app rules to the Cache Engine. LSCache plugins allow you to manage the cache in such a way that more objects may be stored for a longer period, and with unparallelled accuracy.

See more documentation here:
docs.litespeedtech.com/lscache/lscxf/installation/


This is a feature of XenVn add-on, see details here:
https://xenvn.com/threads/xenvn-all-in-one-tools-for-xenforo-2.516/
 
Last edited:

qene10

Member
Vip Member
Whatever we do, unfortunately we never get our forum ratings to 95+. I hope this add-on really works. Unfortunately, I couldn't see any add-ons memory, especially images, css and js parts :(
 

xenvn

Administrators
Staff member
Vip Member
LiteSpeed Cache works only when your website server uses OpenLiteSpeed or LiteSpeed.
 

olalavui

Member
Vip Member
Amazing good job :v
 

qene10

Member
Vip Member
I was very excited when the announcement came out.
I updated the add-on and did everything you wrote.
The result is disappointment... :(

1668883935011.png
 

xenvn

Administrators
Staff member
Vip Member
@qene10

Website optimization takes a lot of time and experience. Fix the problems according to the recommendations given on Gtmetrix and Pagespeed. XenVn add-on only helps to optimize what is in its capacity.

In your case. A lot of problems are waiting for you to solve:
(Search Google to understand and solve each problem)
1668897191049.png




Scores will improve only if you solve the problems they suggest:
1668897384308.png
 

qene10

Member
Vip Member
Unfortunately, I don't know how to solve these problems.
Do you provide consultancy on this matter?
If your answer is "yes", I would like to correspond privately.
 

xenvn

Administrators
Staff member
Vip Member
Unfortunately, I don't know how to solve these problems.
Do you provide consultancy on this matter?
If your answer is "yes", I would like to correspond privately.
I will write a few articles on how to fix the above problems. Wait a few days.
 
Top Bottom