Allows site builders to set cache setting for each block.

Feature

  • Cache timeout
  • Disable cache
  • Force disable cache

Usuage

Go to block overview "admin/structure/block" click "configure" from any block.

Project link

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

Git instructions

git clone --branch 8.x-1.x https://git.drupal.org/project/block_cache.git

PAReview checklist

https://pareview.sh/pareview/https-git.drupal.org-project-block_cache.git

Comments

thihathit created an issue. See original summary.

thihathit’s picture

Issue summary: View changes
thihathit’s picture

Issue summary: View changes
raushan’s picture

Status: Needs review » Needs work

Hi,

Please fix below errors in your module :

1. Please use elseif in place of multiple If condition on line 49 to 57 in module file.
2. Add hook_help() in module file.
3. Add more description in admin UI for better understating.
4. Remove automated testing errors. please check here https://pareview.sh/pareview/https-git.drupal.org-project-block_cache.git

Thanks

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Status: Needs work » Closed (won't fix)

If you are still working on this application, you should fix all known problems and set the status to Needs review. (See also the project application workflow.)
Please don't change status of this application if you aren't sure you have time to dedicate to this application, or it will be closed again as won't fix.

I am closing this application due to lack of activity.

thihathit’s picture

Status: Closed (won't fix) » Needs review

Hi,

I've fixed the coding standard errors, though it's been a while,
https://pareview.sh/pareview/https-git.drupal.org-project-block_cache.git

rksyravi’s picture

Hi @thihathit,

Thank you for your contribution.
everything looks good except the hook_help().

rksyravi’s picture

Status: Needs review » Needs work
avpaderno’s picture

Status: Needs work » Needs review

The absence of hook_help() is not a reason to change status, given that it is going to be replaced.

thihathit’s picture

Currently hook_help() is implemented in .module, Is it required to be replace with newer hook ? Fixed hook_help()

rksyravi’s picture

Hi @thihathit,

No more blocker left.
I just wanted to ask you, does this module disable the cache of anonymous users too.

crafter’s picture

Hi, does it support system block as well? As far as I see that it's only work for custom block created by ui, but what about others system and programming block?

thihathit’s picture

Hi @crafter, It works on any blocks that pass through hook_block_build_alter() since this module alters the cache settings from hook_block_build_alter() so it works including Views.
But there's an exception, if the block has Twig field(e.g: in combination with Twig text filter), It won't work on that field because it is controlled by Drupal's twig cache.

@rksyravi, Haven't tested for sure but it should work theoretically. If it doesn't, might need to make feature request for hook_block_build_alter().

thihathit’s picture

thihathit’s picture

Issue summary: View changes
ankush_03’s picture

@thihathit,

As per comment #12 by @rksyravi

Yes, it is not working for anonymous users, kindly test with anonymous users and I have already tried to bypass block cache for anonymous users in my recent projects but I didn't get any solution.

Let me know your thought for the same.

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

thihathit’s picture

@ankushgautam76@gmail.com, Thank you for testing.

Yes, It turns out not working due to Core's bug related to issues below.
https://www.drupal.org/node/2352009
https://www.drupal.org/node/2835068

Drupal 8 seems to use whole page caching mechanism just like Drupal 7, Unless caching is done using modular caching with block by block caching mechanism instead of whole page, there's no other solution except to disable the caching on the page where a block using this module's feature exists.

So, I've decided to;

  1. just leave the "disable cache" feature as it is. Since this still works unless anonymous user.
  2. add new option, "Force disable page caching on every pages that this block is placed". ofc with a description under the option, saying "Above disable cache doesn't bypass for anonymous user caching but this will allows you to. But you'll lose page caching ability wherever this block appears to."

I'll then obsolete the new option when Core's cache mechanism has been resolved.

thihathit’s picture

StatusFileSize
new1.81 KB
new531 bytes

New option is committed.

Feedback is appreciated.

thihathit’s picture

Issue summary: View changes
klausi’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for your contribution! Code looks good to me, did not see any security issues.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

thihathit’s picture

Thank you @kiamlaluno. And everyone for your kind reviews.

avpaderno’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.