Questions tagged [caching]

Improving the response time, by reducing the amount of processing, in Drupal normally requires using a cache.

Filter by
Sorted by
Tagged with
0 votes
0 answers
30 views

Image inside paragraph being cached

I have a Paragraph type called image - that holds a media reference and also a field which describes how the sibling image should be rendered. I look at the value of the "field_image_style"...
user avatar
0 votes
1 answer
47 views

Proactively rebuild view cache

I have a view that takes a while to build when the cache is cold (around 11s). When the cache is hot, the view loads quickly, of course (around 100ms). I'm using tag-based caching for this view, so ...
user avatar
0 votes
0 answers
54 views

Debugging anonymous session regarding cookie specific page caching

Have been following this guide to make caching depend on the value of a specific cookie: https://cornel.co/article/page-cache-cookiesor-anything-available-http-request-d9 However, it does not seem to ...
user avatar
2 votes
2 answers
176 views

Node ID caching on hook_form_alter()

I have a webform with an email field. I am embedding the webform on each node, with a field on the node for the email address. I implemented hook_form_alter() in my .theme file that loads the node ...
user avatar
2 votes
2 answers
194 views

Is there a way to not include the {{ content }} variable in a node template and still have the node cache clear when the node is updated?

We have nodes that have dozens of fields and have elected to not include the {{ content }} variable as it is tedious and looks messy having something like the following just to not print the fields. ...
user avatar
0 votes
2 answers
90 views

Which cache should I invalidate in a block plugin that builds render arrays for one or more views?

The real issue is that the plugin will sometimes be returning render arrays that are discrete block displays from the same view, possibly also with different arguments. What I'm discovering is that in ...
user avatar
  • 349
2 votes
1 answer
156 views

Why are cookies being caches in hook_prepress_node() and how can I prevent or work around this issue?

In Drupal 9 we have a _preprocess_node() hook that loads a users cookies like: function THEME_preprocess_node(&$variables) { $parameters = []; if (isset($_COOKIE['utm_source'])){ $...
user avatar
0 votes
1 answer
65 views

Wrong user page loaded after user_login_finalize()/user_logout()

I have a third party login custom module that calls user_login_finalize() after authentication, and user_logout() upon logout. Both of these functionalities work except if the user logs in/out from ...
user avatar
  • 253
1 vote
1 answer
134 views

Wrong user with currentUser() on prod

I'm getting the name of my user that I load from the profile. It's works fine on my local, but on my prod, the firstname displayed is showing the name from the previous user. How do I prevent that ? ...
user avatar
  • 51
0 votes
1 answer
88 views

Entity caching and computed fields

I have a custom entity that I've added some computed fields to, so the classes involved are: class MyEntity extends ContentEntityBase class ComputedFieldA extends FieldItemList class ComputedFieldB ...
user avatar
  • 640
0 votes
0 answers
34 views

Clear specific view's cache programmatically, specific to contextual filter

I am using the following to clear view specific cache on node_presave which is working fine. cache_clear_all($view_name.':'.$display_name, 'cache_views_data', TRUE); Currently, it is deleting all ...
user avatar
1 vote
0 answers
37 views

Is there a way to fetch cache keys by a pattern or a cache tag

I was trying to find if there is a way to fetch or count Drupal cache keys that match a pattern. I couldn't find a function in the CacheBackendInterface that does this. The context is that I was ...
user avatar
  • 882
1 vote
1 answer
59 views

Add simple config object as a cacheable dependency?

I am building a custom breadcrumb that has some admin settings from a module in Drupal 9. When that settings form is saved, I want any breadcrumb cache that was built with this builder to be ...
user avatar
  • 26.5k
0 votes
1 answer
54 views

Error on local clone (MAMP)

I cloned a version of a Drupal 8.9.20 site to a local installation (MAMP PRO). That seemed to word, but when I call the site I get an error: The website encountered an unexpected error. Please try ...
user avatar
0 votes
1 answer
59 views

Middle part of a page disappears and appears again after flushing all caches

Sometimes middle part of some page at our website may disappear and only header and footer are still displayed. The problem is always solved after flushing all caches. Our html.html.twig loads ...
user avatar
0 votes
0 answers
35 views

What cache tags can be triggered by a change in state variables?

If I want my render array to indicate to Drupal that it should be rebuilt when, say, node 1 changes, I can do something something like this: $my_render_array = [ ... '#cache' => [ 'tags' =&...
user avatar
  • 205
0 votes
2 answers
61 views

How to cache View block by content language?

I have a very simple (block) view to list a node's title. This view has an id from url contextual filter and a single filter to filter on Content language set for the page (by URL prefix). This block ...
user avatar
  • 907
0 votes
0 answers
18 views

Does Views block caching include language in cid?

I think this is likely a core bug (in which case I know it is not meant for Drupal Answers) but thought I would check here first to see if possibly I have just missed something in configuration? I ...
user avatar
  • 907
-3 votes
1 answer
77 views

How to track recently viewed nodes using JavaScript on a completely cached website?

I want to make a block of recently viewed nodes on a website which is completely cached using Boost module (it saves a static HTML page for every request on the website). I don't want to disable Boost ...
user avatar
  • 1
1 vote
0 answers
43 views

Setting latest revision has been delayed

We are (still) using Drupal 8, the latest version, as a CMS for content editing. Our platform is huge and it has 100+ editors who are constantly adding/editing content, and also 20 importers which are ...
user avatar
0 votes
0 answers
146 views

How can I debug cache tags not invalidated as expected?

Up unto last week my Drupal site and varnish_purge worked together fine with Varnish. After updating the modules to the latest versions, cache tag invalidation seemed to stop. Nothing else really ...
user avatar
  • 227
0 votes
0 answers
29 views

Content and content type fields intermittently disappear after cache rebuild

I have an issue on a Drupal 9 website where sometimes (but not every time), if I run drush cr the content of pages disappears (the header and footer are all that remain), and in Structure > Content ...
user avatar
  • 423
0 votes
0 answers
30 views

Is there a way to not render blocks for mobile devices that works for anonymous users?

I'm trying to dynamically render a block on for desktops. I've tried detecting in a page preprocess and using the set variable to dynamically render the block in the page template but there seems to ...
user avatar
1 vote
1 answer
76 views

Render view inside block with caching

My setup is a bit unconventional. I have a view displaying a block, relying on a contextual filter (let's call it product ID). I also have a custom block that renders this view programmatically ...
user avatar
  • 632
0 votes
1 answer
53 views

Where to define custom entity caching rules of detail pages

When you have a larger project you probably have both internal page cache as internal dynamic page cache module enabled. In my case I do. But I have a section on my website containing custom entities (...
user avatar
0 votes
1 answer
124 views

EventSubscriber to add cache context for specific path

I am working with Mobile Detect module and from what I understand, we need to manually add the cache context mobile_detect_is_mobile in order to have the page cached differently based on the user ...
user avatar
  • 103
1 vote
2 answers
173 views

Cloudflare cache everything

we have a Drupal 8 with Cloudflare cache rule. By default we have always GBP currency, then we developed a module that allow users change their currency with a footer dropdown and saves it on the user ...
user avatar
  • 131
0 votes
1 answer
83 views

How can I have a custom block show different content on the front page?

I have a custom module, in Drupal 9, (showing a block in a region) that has an admin form with a checkbox for showing only on the "front page" or if unchecked on "all" pages. In ...
user avatar
-1 votes
1 answer
88 views

How to handle different output for a same block (Caching Problem)? [duplicate]

I have a theme which has two different appearance for main menu block, so I wrote a theme suggestion like this: function MYTHEME_theme_suggestions_menu_alter(array &$suggestions, array $variables) ...
user avatar
0 votes
0 answers
21 views

Using memcached and ip_ban simultaneously?

Memcached is by no doubt an essential tool to speed up Drupal websites. Is there a way to use the ip_ban module in order to block certain countries from accessing my website before the cached content ...
user avatar
  • 101
1 vote
1 answer
202 views

Custom block is still caching for anonymous users despite getCacheMaxAge() being set to 0 and can't figure out why

I have a custom Drupal 8 block with class with build() and getCacheMaxAge() functions. getCacheMaxAge() is set to 0 but it is still being cached for anonymous users. If I put debug code in the build() ...
user avatar
1 vote
1 answer
169 views

How to invalidate Breadcrumbs cache for child nodes on graphQl

I have for example Node A with alias node-a and Node B with alias node-a/node-b so on my Node B i have this breadcrumb Home > Node A > Node B GraphQl result: "breadcrumb": [ ...
user avatar
  • 6,577
0 votes
1 answer
178 views

How do I grant to a role the permission to flush the cache?

I removed the Administer site configuration permission from a role, but I need users with that role to flush the cache from /admin/config/development/performance. I know, there is hook_menu_alter() in ...
user avatar
-1 votes
1 answer
150 views

Can't get page html after updating the page and flushing all caches

Once I updated a page via admin panel, I need to programatically flush all the caches, then get the page source code and write it to a file. I use the following code inside of my module: function ...
user avatar
  • 123
3 votes
1 answer
259 views

Can BigPipe exclude certain blocks?

I've got BigPipe enabled in Drupal 8, and it helps to make pages initially load faster. However, the header block is always one of the blocks that loads in on a delay, which visually looks bad since ...
user avatar
0 votes
0 answers
66 views

If I am using PrivateTempStoreFactory, should I be using the Internal Page Cache Module?

I found a Stack Exchange question here that kind of answers this question, but I was not clear about the answer from the exchange in the comments. Regardless of the reason I am using ...
user avatar
0 votes
0 answers
62 views

How is the cache invalidated?

Using the following code, are all the cache bins consider when invalidating a content piece? $variable['#cache'] => [ 'keys' => ['key string here'], 'tags' => ['tags string here'], 'max-...
user avatar
  • 321
0 votes
0 answers
74 views

Create cache context for anonymous users based on ip range

I have a form within a custom block that is displayed on the front page of a Drupal 9 site on Acquia Cloud. I want to be able to have different displays for users coming from certain ip ranges. Is ...
user avatar
  • 2,289
2 votes
1 answer
346 views

Debugging "UNCACHEABLE" header

We have a site where the homepage is not being cached and contains the headers: x-cache: MISS, MISS x-cache-hits: 0, 0 x-content-type-options: nosniff x-drupal-dynamic-cache: UNCACHEABLE I narrowed ...
user avatar
  • 26.5k
1 vote
1 answer
1k views

drupal9 dev mode local settings : non existing cache.backend.null

In drupal9 my drupal8 local.settings.php conf generate an error when i empty cache Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have [error] requested a non-...
user avatar
  • 2,775
1 vote
1 answer
98 views

is it possible to deactive twig cache for a single theme custom template?

i am having a custom template for rendering a medialink url from a paragraph media entity ref field. In production with twig cache activated, modifiying the media attached file , does not update the ...
user avatar
  • 2,775
3 votes
1 answer
87 views

How to invalidate the block list cache?

I need to invalidate the block list cache each time a new configuration entity is created, this is because I have a derivative block to handle dynamically one block for each of my configuration ...
user avatar
0 votes
1 answer
41 views

Class Drupal\dfm\EventSubscriber\DfmSubscriber not found when try to remove the Drupella File Manager

I installed the Drupella File Manager module for Drupal 8.8, but I have Drupal 8.7. I received this error. Call to undefined method Drupal\Core\File\FileSystem::scanDirectory() I don't need the ...
user avatar
  • 123
0 votes
0 answers
92 views

Use Injected CacheBackedInterface to invalidate certain bin

I've got a content type called SERVICE (I write it all capitalized to prevent mixture with drupal service) which admin can introduce different SERVICE using this type, it is expected that these ...
user avatar
0 votes
0 answers
182 views

Antibot Failing when Webform Embeded in Gutenberg

When enabling Antibot on a Webform rendered through Guntenberg, I can not submit the form. Create a "Custom Webform" block type with a single entity reference field for Webforms. Create a ...
user avatar
  • 1,720
1 vote
1 answer
73 views

Symfony\Component\HttpFoundation\Response is never cached

My custom controller is returning data but it is never being cached. My controller function: use Symfony\Component\HttpFoundation\Response; $build = [ '#theme' => 'search_form_suggest'...
user avatar
1 vote
0 answers
86 views

Clearing Cache related to user data

Drupal's cache system is a complete nightmare causing all sorts of issues with my user sessions. To provide a couple examples Our navigation header block contains a link that takes users to a ...
user avatar
0 votes
1 answer
353 views

How to deal with block cached for anonymous user?

I have placed in the site's home, via twig, a views block of nodes with a random sort and obliviously no cache active. Therefore, at each page reload different nodes appear. The problem is that block ...
user avatar
  • 490
0 votes
2 answers
205 views

Is there any way to clear the cache with specific cid?

I set some data in cache using cache_set($cache_id, $temp_data, 'cache', CACHE_TEMPORARY); from a custom module. It's cleared when I clear all the cache. Is there any way I can clear that specific ...
user avatar
  • 1
1 vote
0 answers
26 views

Cache rebuild take a long time and block all user request

The main problem I have is cache rebuilds, which take a while, and block all user requests until the rebuilds are complete. I would like to find a way to make it so the rebuilds aren't quite as deadly ...
user avatar

1
2 3 4 5
28