GithubHelp home page GithubHelp logo

lscache-drupal's Issues

After upgrading to D10, css/js are broken on some pages

I upgraded a site from D9 to D10.

This site was using Litespeed Drupal module (v 1.2) on D9.

On D10, I used v1.5.

End result: some pages worked and some did not.

I disabled all caching and css/js aggregation. Problem still persists.

For the pages that did work, the correct css/js files are accessed.

For the pages that didn't work, Drupal is trying to get the optimized css/js files but they do not exist (this is with css/jss disabled).

When I checked the Drupal logs I see:

Symfony\Component\HttpKernel\Exception\BadRequestHttpException: The theme must be passed as a query argument in Drupal\system\Controller\AssetControllerBase->deliver() (line 132 of /code/web/core/modules/system/src/Controller/AssetControllerBase.php).

When I uninstall the LiteSpeed Drupal module, everything works perfectly.

I don't know if this issue is related, but here it is anyway: https://www.drupal.org/project/drupal/issues/3393274

I have resorted to not using the Drupal Litespeed module until this is fixed.

Let me know if you need any additional info. I have the db backup on D10 with Litespeed enabled.

Just to note, I am not 100% sure if this is the fault of the Litespeed module or just my hosting. My hosting is using Litespeed webserver and was working perfectly using D9 and Litespeed v1.3.

It's difficult to test this locally. Locally, I am using ddev with nginx so I cannot replicate the problem locally.

Drupal 8.6.x issue: TypeError: Argument 2 passed to Drupal\page_cache\StackMiddleware\PageCache::storeResponse()

I get the following error for image generating (and other files too) since upgrading to Drupal 8.6.x (Currently on 8.6.7):

TypeError: Argument 2 passed to Drupal\page_cache\StackMiddleware\PageCache::storeResponse() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in /home/saschaeg/public_html/saschaeggenberger.com/core/modules/page_cache/src/StackMiddleware/PageCache.php on line 188 in Drupal\page_cache\StackMiddleware\PageCache->storeResponse() (line 205 of /home/saschaeg/public_html/saschaeggenberger.com/core/modules/page_cache/src/StackMiddleware/PageCache.php) #0 /home/saschaeg/public_html/saschaeggenberger.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(188): Drupal\page_cache\StackMiddleware\PageCache->storeResponse(Object(Symfony\Component\HttpFoundation\Request), NULL) #1 /home/saschaeg/public_html/saschaeggenberger.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(121): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true) #2 /home/saschaeg/public_html/saschaeggenberger.com/core/modules/page_cache/src/StackMiddleware/PageCache.php(75): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true) #3 /home/saschaeg/public_html/saschaeggenberger.com/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #4 /home/saschaeg/public_html/saschaeggenberger.com/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #5 /home/saschaeg/public_html/saschaeggenberger.com/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #6 /home/saschaeg/public_html/saschaeggenberger.com/core/lib/Drupal/Core/DrupalKernel.php(693): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /home/saschaeg/public_html/saschaeggenberger.com/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #8 {main}.

These must be a change of passed arguments from 8.5.x to 8.6.x

Breaks first Commerce "Add to cart" for anonymous users

For some reason clicking "Add to cart" for a Commerce product the first time does not result in a new session cookie being saved. Although the product is added, there is no visible sign of this, confusing the customer.

I think the Product page is being cached for the "no cookie" state, and not refreshed when Commerce sets a cookie for the cart.

Turning off lscache in the Drupal admin settings fixes the problem.

Drupal 8.8.0 : TypeError: Argument 2 passed to Drupal\page_cache\StackMiddleware\PageCache::storeResponse()

When I try to log in I get the following message:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Drupal\page_cache\StackMiddleware\PageCache::storeResponse() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in /home/naukispo/domains/nauki-spoleczne.info/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php on line 195 in Drupal\page_cache\StackMiddleware\PageCache->storeResponse() (line 212 of core/modules/page_cache/src/StackMiddleware/PageCache.php).

I use litespeed and memcached.

Undefined constant MAIN_REQUEST

After upgrading Litespeed from 1.2 to 1.3, I am getting WSOD. Upon checking the logs, I see this:

php Error: Undefined constant Drupal\lite_speed_cache\StackMiddleware\LiteSpeedCache::MAIN_REQUEST in
                                            Drupal\lite_speed_cache\StackMiddleware\LiteSpeedCache->handle() (line 109 of...

I can see from this latest commit that MAIN_REQUEST is being used instead of MASTER_REQUEST.

MASTER_REQUEST is required for HttpKernelInterface:

interface HttpKernelInterface
{
    public const MASTER_REQUEST = 1;
    public const SUB_REQUEST = 2;

    /**
     * Handles a Request to convert it to a Response.
     *
     * When $catch is true, the implementation must catch all exceptions
     * and do its best to convert them to a Response instance.
     *
     * @param int  $type  The type of the request
     *                    (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
     * @param bool $catch Whether to catch exceptions or not
     *
     * @return Response A Response instance
     *
     * @throws \Exception When an Exception occurs during processing
     */
    public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
}

Would be great if this can be fixed asap as I cannot use Litespeed anymore. I'll need to revert to 1.2 for now.

Tags based invalidation not working because LSCacheTagsInvalidator::$tags gets overwritten

Editing content does not purge LSCache tags automatically at the moment because wrong tags are sent in the X-LiteSpeed-Purge HTTP response header.

If we are editing node 48 in Drupal for example, the correct cache purge tag list would be something like4xx-response,node:48,node_list but for example tags 4xx-response,menu_link_content:33,menu_link_content_list are actually set in the header.

Because of this, only way to purge cache successfully is manual Clear this site or Clear all operation from the LSCache module settings.

Debug logging the LSCacheTagsInvalidator -> invalidateTags function reveals that correct tags are first populated to LSCacheTagsInvalidator::$tags but it gets overwritten with subsequents calls that produce route_match, menu_link_content and menu_link_content_list tags which are incorrect for purging the cache. The last iteration is what gets actually sent in the X-LiteSpeed-Purge header.

Feature Request: Vary cache based on Drupal user roles

Often different Drupal roles require different page contents. For instance, anonymous may require different content than authenticated and admin will require different content than both anonymous and authenticated. It is typical that admin should not be cached, but quite often pages for authenticated user roles are all the same for the role and so can be cached.

LSCache does not differentiate between authenticated and admin roles. When users authenticate, LSCache sets _lscache_vary to 'loggedin' no matter the user role, thus, unless private cache is set, pages are not cached for authenticated users. But for large sites with thousands or tens of thousands of users, private cache is untenable. Caching per user role will increase the number of cached pages, especially when there are multiple roles below the admin level, but will be more efficient than using private cache.

Preferably, LSCache Drupal module would support the feature of varying cache based on defined user roles, as by the site administrator.

Currently, this feature is supported with Varnish + Advanced Varnish Drupal module. For reference, the Advanced Varnish module allows site administrators to turn on cache for authenticated users. For example, when the user role 'authenticated' is allowed to cache, the Advanced Varnish Cache module sets two cookies: ADVINF and ADVBIN. The former specifies the roles the authenticated user possesses, while the latter specifies the appropriate cache bin for the user. The ADVBIN value varies depending on the user role such that all roles that should be cached have a unique bin value, i.e., if ADVINF=authenticated, ADVBIN=1234, but if ADVINF=authenticated_other, ADVBIN=5678. Thus the vary header says to look for the bin info in the cookie and serve the corresponding cached page for the role. When a role should not have pages cached for it, no ADVINF or ADVBIN cookies are set. On logout, if the cookies are set the values are deleted.

https://www.drupal.org/docs/contributed-modules/advanced-varnish/cache-for-authenticated-users
https://www.drupal.org/project/adv_varnish

You are referring to page cache and not dynamic page cache.

In Drupal there are two types of caches.

Page cache that works for anonymous users.
Dynamic page cache - that caches parts of the page and generates only the non-cache-able parts from it.

From what I see in the code and descriptions in this module, you are making alternative variant for the page cache, but stating dynamic page cache everywhere.

You need to extend also documentation on what users installing this module should do with the core's dynamic page and standard page cache modules. Having both running at the same time is likely not needed.

Proper benchmarks comparing D8 core with and without the plugin will be appreciated.

Upgrade for Drupal 10

I may well do the work for this, but do not yet have time.

The two issues picked up by PHPstan are:

File: web/modules/contrib/lite_speed_cache/src/EventSubscriber/LiteSpeedCacheSubscriber.php
Line: 128
Comment: Parameter $event of method Drupal\lite_speed_cache\EventSubscriber\LiteSpeedCacheSubscriber::onRouteMatch() has typehint with deprecated class Symfony\Component\HttpKernel\Event\GetResponseEvent: since Symfony 4.3, use RequestEvent instead

File: web/modules/contrib/lite_speed_cache/src/EventSubscriber/LiteSpeedCacheSubscriber.php
Line: 166
Comment: Parameter $event of method Drupal\lite_speed_cache\EventSubscriber\LiteSpeedCacheSubscriber::onResponse() has typehint with deprecated class Symfony\Component\HttpKernel\Event\FilterResponseEvent: since Symfony 4.3, use ResponseEvent instead

and the .info.yml file needs to have "^9 || ^10" as the version requirement.

Works only on the homepage

I can see the headers X-LiteSpeed-Cache: hit or X-LiteSpeed-Cache: miss only in the homepage. I cannot see these headers in other pages of the site.

How to reproduce
I added this module to an existing site, enabled the module and enabled the Debug option.

Expected behavior
I would expect to see a hit or a miss on every page.

Things I've tried

  1. I have looked at the pages as an anonymous user.
  2. I've also tried using Chrome Incognito Mode.
  3. I have uninstalled the core Drupal Internal Page Cache module suspecting a conflict while leaving installed the Dynamic cache module.

Thank you for your work on this module.

Upgrade problem

I upgraded my v1.0 lscache Drupal module to v1.2 by putting the site in maintenance mode, then copying the files over. After doing this, my site was broken. I recovered by replacing the module files, then found this in the Drupal log:

Error: Class 'Drupal\lite_speed_cache\StackMiddleware\LiteSpeedCache' not found in Drupal\Component\DependencyInjection\Container->createService() (line 262 of /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php)
#0 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
#1 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
#2 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(240): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#3 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
#4 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
#5 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(240): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#6 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
#7 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
#8 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(240): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#9 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_middleware...')
#10 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(437): Drupal\Component\DependencyInjection\Container->get('http_middleware...', 1)
#11 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(240): Drupal\Component\DependencyInjection\Container->resolveServicesAndParameters(Array)
#12 /home/nature50/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(176): Drupal\Component\DependencyInjection\Container->createService(Array, 'http_kernel')
#13 /home/nature50/public_html/core/lib/Drupal/Core/DrupalKernel.php(1370): Drupal\Component\DependencyInjection\Container->get('http_kernel')
#14 /home/nature50/public_html/core/lib/Drupal/Core/DrupalKernel.php(717): Drupal\Core\DrupalKernel->getHttpKernel()
#15 /home/nature50/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#16 {main}

I managed to do the upgrade by uninstalling the old module, replacing it, then re-installing it.

Drupal messages

If status, warning, or error messages are added, they do not get displayed as the page loads from cache. For example, adding a new node as an anonymous user results in a message being displayed on the home page. This does not show up.

Drupal 9 compability

Please fix the following to be compatible with Drupal 9:
modules/contrib/lscache/src/Form/LSCacheForm.php | 167 | Call to deprecated function drupal_set_message(). Deprecated in drupal:8.5.0 and is removed from drupal:9.0.0. Use Drupal\Core\Messenger\MessengerInterface::addMessage() instead.

modules/contrib/lscache/src/Form/LSCacheForm.php | 175 | Call to deprecated function drupal_set_message(). Deprecated in drupal:8.5.0 and is removed from drupal:9.0.0. Use Drupal\Core\Messenger\MessengerInterface::addMessage() instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.