Port to Drupal 8 - attached the patch. Also I would like to be co-maintainer of this module.

CommentFileSizeAuthor
cacheexclude-d8port.patch9.31 KBjeqq
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost’s picture

Status: Needs review » Needs work

A bit outdated according https://www.drupal.org/node/2323571

  1. +++ b/cacheexclude.services.yml
    @@ -0,0 +1,5 @@
    +services:
    +  cacheexclude.event_subscriber:
    +    class: Drupal\cacheexclude\EventSubscriber\CacheExcludeSubscriber
    
    +++ b/src/EventSubscriber/CacheExcludeSubscriber.php
    @@ -0,0 +1,59 @@
    +    $config = \Drupal::config('cacheexclude.settings');
    ...
    +    $path_matcher = \Drupal::service('path.matcher');
    

    should be injected

  2. +++ b/src/EventSubscriber/CacheExcludeSubscriber.php
    @@ -0,0 +1,59 @@
    +      drupal_page_is_cacheable(FALSE);
    ...
    +        drupal_page_is_cacheable(FALSE);
    

    Is gone should be implemented on top of page_cache_response_policy

  3. +++ b/src/Form/CacheExcludeSettingsForm.php
    @@ -0,0 +1,69 @@
    +class CacheExcludeSettingsForm extends ConfigFormBase {
    ...
    +    $config = \Drupal::config('cacheexclude.settings');
    ...
    +    \Drupal::config('cacheexclude.settings')
    

    needs getEditableConfigNames()

yang_yi_cn’s picture

I tried many ways and neither drupal_page_is_cacheable nor page_cache_response_policy seem to work at all.

In the end I used this method: https://pantheon.io/docs/cache-control/

By definiing a custom block with $build['#cache']['max-age'] = 0; and name it "non cacheable block", place the block on any page you don't want to cache and that page will not be cached.

I believe the block settings should have covered most of the use cases like by page, by content type, by language, by user role etc.

You need to completely rewrite this module that way though.

agentrickard’s picture

I've given https://www.drupal.org/u/gobinathm maintainer access at his request, to try to jumpstart this issue.

yang_yi_cn’s picture

hmm... recently I learned there's a thing called cache killswitch in D8:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21PageCache...

If block #cache setting doesn't work, it looks like we can try to use this KillSwitch instead. It seems to be working and taking effect in pretty early stage.

naiduharish’s picture

Status: Needs work » Closed (duplicate)

I have released D8 dev version for this module. Please follow https://www.drupal.org/node/2868317