[1.0.x] Page Cache Exclusion

Created on 11 September 2024, 2 months ago
Updated 18 September 2024, about 2 months ago

Page Cache Exclusion module provides a simple way to exclude certain pages from being cached.
3 exclude options are available:
- Exclude pages when query parameters are present
- Exclude pages that returns status codes 4XX
- Exclude pages based on url

Project link

https://www.drupal.org/project/page_cache_exclusion

📌 Task
Status

Needs review

Component

module

Created by

🇱🇧Lebanon joseph28 France, France, Monaco & Qatar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joseph28
  • 🇮🇳India vishal.kadam Mumbai

    Thank you for applying!

    Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.

    The important notes are the following.

    • If you have not done it yet, you should run phpcs --standard=Drupal,DrupalPractice on the project, which alone fixes most of what reviewers would report.
    • For the time this application is open, only your commits are allowed.
    • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status won't be changed by this application and no other user will be able to opt projects into security advisory policy.
    • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

    To the reviewers

    Please read How to review security advisory coverage applications , Application workflow , What to cover in an application review , and Tools to use for reviews .

    The important notes are the following.

    • It is preferable to wait for a Code Review Administrator before commenting on newly created applications. Code Review Administrators will do some preliminary checks that are necessary before any change on the project files is suggested.
    • Reviewers should show the output of a CLI tool only once per application.
    • It may be best to have the applicant fix things before further review.

    For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues .

  • Status changed to Needs work 2 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    • The following points are just a start and don't necessarily encompass all the changes that may be necessary
    • A specific point may just be an example and may apply in other places
    • A review is about code that does not follow the coding standards, contains possible security issues, or does not correctly use the Drupal API; the single points are not ordered, not even by importance

    This is quick review. I will do a more complete one when I have more time.

    src/Form/PageCacheExclusionConfigForm.php

        $config = $this->configFactory->getEditable('page_cache_exclusion.settings');
        $config->set('page_query_parameters_list', $form_state->getValue('page_query_parameters_list'));
        $config->set('page_list', $form_state->getValue('page_list'));
        $config->set('client_error_caching', $form_state->getValue('client_error_c
    

    There is no need to call $this->configFactory->getEditable(). It is sufficient to call $this->config().
    $config->set() returns the configuration object, so multiple calls to set() can be chained.

    src/StackMiddleware/PageCacheAlter.php

      /**
       * {@inheritdoc}
       */
      public function __construct(HttpKernelInterface $http_kernel, CacheBackendInterface $cache, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, ConfigFactoryInterface $config_factory, AliasManagerInterface $alias_manager, PathMatcherInterface $path_matcher, CurrentPathStack $current_path) {
        parent::__construct($http_kernel, $cache, $request_policy, $response_policy);
        $this->config = $config_factory->get('page_cache_exclusion.settings');
        $this->aliasManager = $alias_manager;
        $this->pathMatcher = $path_matcher;
        $this->currentPath = $current_path;
      }
    

    {@inheritdoc} is not used for class constructors.

    core/modules/page_cache/src/StackMiddleware/PageCache.php

    Stack middleware implementations done by Drupal core and its modules are internal API. Classes like Drupal\page_cache\StackMiddleware\PageCache cannot be used as parent class.

  • Status changed to Needs review 2 months ago
  • 🇱🇧Lebanon joseph28 France, France, Monaco & Qatar

    hello @avpaderno,

    Thank you for taking the time to review the module.

    I corrected the points mentioned in your comment except:

    core/modules/page_cache/src/StackMiddleware/PageCache.php

    Stack middleware implementations done by Drupal core and its modules are internal API. Classes like Drupal\page_cache\StackMiddleware\PageCache cannot be used as parent class.

    I am not sure I understand what's the problem nor the alternative.
    Correct me if I am wrong but for me the purpose of the contrib modules is to extend core functionnalities, also I did find many modules extending PageCache ( ex: Advanced Internal Page Cache )

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The problem is that backward-compatibility changes are only done for public API.
    There is just an alternative: Extend only classes that are part of the public API, like base classes.

  • 🇱🇧Lebanon joseph28 France, France, Monaco & Qatar

    hello @avpaderno,

    Ok I get your point and as I see we have 2 solutions:
    - Implement HttpKernelInterface instead of extending PageCache but this will lead to redefining the entire pageCache class in our new class
    - Use a service instead of a StackMiddleware but this beats the purpose of the module because we are trying to do it without bootstraping drupal

    Can you give us your opinion on these 2 solutions?
    Do you see other possibilities?

  • 🇮🇳India rushiraval

    I am changing priority as per Issue priorities .

Production build 0.71.5 2024