As of May 31, 2023, we have updated our Code of Conduct.

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
1 vote
0 answers
43 views

User-specific caching, but not necessarily the current user

Background I'm creating a render array that is built for a specific user, from data related to that user. The resulting render array is dependent on the user ID that is passed in, and it will be ...
mbomb007's user avatar
  • 479
-1 votes
0 answers
59 views

drupalSettings not displayed with cache disabled

I have a custom block '#attached' => [ 'drupalSettings' => [ 'myblock' => $settings ], ... When I do not turn off cache, the settings are properly written into JS variables and I ...
Ari's user avatar
  • 1
1 vote
1 answer
61 views

How to invalidate custom block which use Cache Tags and Cache contexts for authenticated user?

I'm working on an application where authenticated user data mostly comes from an API. Performance is significantly better since I'm using the API cache. Before, to be sure to have up-to-date ...
Sébastien Gicquel's user avatar
0 votes
2 answers
78 views

How do I disable caching of a custom token?

I have created a custom token which reads values from the Apache Request Headers. It seems to work fine for my testing, but then when another user subsequently accesses the token, it uses my values. ...
Kevin Finkenbinder's user avatar
0 votes
0 answers
19 views

Views posts not displaying correctly until clearing the cache

I have an issue with a Drupal 8 website. I have some pages that have views listing some contents ( text and images). The websites uses CDN and varnish. The problem is that sometimes, the contents like ...
el sparrow's user avatar
0 votes
1 answer
83 views

Adding cache tags to custom block

I have a custom block which load some taxonomy terms. When I made changes to my taxonomies, the block isn't loading the new data (due to the cache). I'm passing all my taxonomy tags to my #cache ...
lobafox's user avatar
  • 99
0 votes
1 answer
74 views

Is it possible to recreate cache tables from a more fixed source?

I am working with a dockerized Drupal environment in which we want to track content alongside our theme, modules, etc in source control. We achieve content tracking by using mysqldump to dump the ...
Brian Gradin's user avatar
1 vote
1 answer
41 views

Cache two sets of nodes [closed]

I have a website where I have some blocks that have one content on all nodes, but different content on nodes with certain NID. Right now, I have condition in block template based on node ID and blocks ...
Klemen's user avatar
  • 11
0 votes
0 answers
53 views

How to modify the "href" attribute of some of the links of an html field type?

I'm using drupal 9.4.8 and I have a content type called "articles" which has a "body" field (which is a reference to a paragraph) and I'm making an algorithm to check all the ...
LeJuanChis's user avatar
1 vote
1 answer
50 views

Are media entity Ajax calls cached?

In my Drupal 9 site with CKEditor 4 and I have created "media gallery" media type, which displays set of images (using slideshow module). So, when I click "insert media" CKEditor ...
MilanG's user avatar
  • 485
2 votes
1 answer
116 views

How can I test Max-age on cache?

I have a Controller using cache tags. I have just been asked a change that requires a Max-age also (show next event starting from current time); I explained that the only way to have this is with some ...
Francesco Marchetti-Stasi's user avatar
2 votes
1 answer
228 views

How to programmatically invalidate the cache of every node

I have a form submit function that is meant to invalidate the cache of every node if a specific field is altered. Here's how I'm attempting it. $config = $this->configFactory ->getEditable('...
Matt's user avatar
  • 5,482
0 votes
0 answers
87 views

How can I Speed up Cache calls?

I have a site with a few complicated forms. They require a lot of CPU time to calculate, so I am caching the $form array in order to be able to deliver the form quickly to the user. To do this, I am ...
Hershel's user avatar
  • 153
2 votes
1 answer
83 views

How can you cache a form render array?

I have a custom module which builds a set of complicated forms, and these forms are built dynamically (the option lists for certain SELECT items, for example, are fetched via an API call). Some of ...
Hershel's user avatar
  • 153
0 votes
1 answer
91 views

How can I bust the cache for the toolbar?

I am creating a drupal module and here in the module file i created a check on hook_toolbar() function that if there are credentials in the database it will show 4 links in dropdown otherwise it will ...
Manav Chauhan's user avatar
1 vote
1 answer
90 views

Service continues to act as shared when shared is set to false

According to Symfony docs, doing shared: false on a service should mean that each time you call a service, you get a new instance. However, this doesn't seem to work for me. I am using Drupal 9 which ...
pixel5's user avatar
  • 96
0 votes
1 answer
45 views

Excluding individual page components from caching

I can't seem to find a straight answer online about whether it is possible to exclude just one component of a page from being cached. My component appears on all pages of the site and comes from a ...
arrr_matey's user avatar
1 vote
0 answers
56 views

How to invalidate config or service cache

I have a service wich is loading a config at construct time: class MyService { public function __construct(ConfigFactoryInterface $config_factory) { $config = $config_factory->get('my.config')...
Baud's user avatar
  • 458
1 vote
1 answer
319 views

What cache service should I use?

I just used a cache service explicitely for the first time, in a function that calls a remote service. The result is a simple string that may change day by day, but it's very rare that it changes for ...
Francesco Marchetti-Stasi's user avatar
0 votes
1 answer
50 views

What is the difference between Platform CDN and Cloudflare? [closed]

The cloud provider I use(Acquia) has a set of API endpoints, and one of them is to clear caches, including Platform CDN + Varnish. When I read Platform CDN, it gets me wonder where Cloudflare then ...
user agent's user avatar
1 vote
0 answers
88 views

Why does placing a menu block on a page stop the page from being cached for anonymous users?

If I show a menu block on a page, that page will never be cached for anonymous users. Is that expected behaviour or is it caused by something else on our site? If it is caused by something else, ...
user5113's user avatar
2 votes
0 answers
30 views

Changes in email template are saved, but not used (cache?)

I'm usually trying to find an answer/clue on my own, and usually it works, but at this time search is fruitless. So I'm trying to edit a welcome email text, using /admin/config/people/accounts section....
Basil Vlasyuk's user avatar
3 votes
1 answer
461 views

How do I properly cache a menu item that varies by user?

We are attempting to show a users first name on a profile menu for authenticated users. We added a lazy builder to the hook_preprocess_page hook in our theme given this is highly dynamic content on ...
Ryan Eastabrook's user avatar
0 votes
1 answer
606 views

How can I fix the "Predis\Client not found" error?

I have a project based on Drupal 7. I installed PHP 7.4, Redis, and php-redis on Ubuntu. I get a Class 'Predis\Client' not found error. The values in the setting.php file for the module are the ...
mohammad nabipour's user avatar
1 vote
0 answers
131 views

Need help with Cache::invalidateTags() and cacheable metadata in REST route

I have a REST route that returns some JSON. I am trying to get cache tags working correct, but it doesn't seem to be working. Only updates if I flush all cache. I have a queue that runs on cron every ...
Ronnie's user avatar
  • 447
0 votes
0 answers
66 views

Block cache for anonymous users depending on previous behavior

I have a content type named "Campaign". Each Campaign has a totally different look and feel in the website. Once a visitor wants to join a campaign, the user is redirected to the normal ...
juankvillegas's user avatar
2 votes
1 answer
141 views

Which PHP parameter do I need to tweak in order to fix the PHP APCU CACHING site status warning?

I get a memory warning in my Drupal site, but I still have sufficient free memory on the server. Which parameter do I need to tweak in order to fix this warning?
Wayne Foster's user avatar
-3 votes
1 answer
159 views

What is the relationship between internal page cache and dynamic page cache?

I faced a problem in my browser. Firstly, I removed an internal cached page that could be accessed by anonymous authenticated users. The page was still cached from the dynamic page cache. I accessed ...
A.Saku's user avatar
  • 1
0 votes
0 answers
381 views

"LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected."

Hi I've created a module with a controller but now i'm getting this message; The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you ...
skycomputer2's user avatar
0 votes
1 answer
89 views

Toggle (show or hide) visibility of content type field in view depending on relationship with other content type

I have a member content type that displays info about a company's member. One of the fields is named member publications, and it's a link to a blog view where the publications of the member (another ...
Gabri's user avatar
  • 3
0 votes
1 answer
83 views

Request does not reach controller after a few requests

I have a custom module for an online shop. Module's controller gets a product id which is sent by the user through a query string and puts it into the session. That is crucial for the shopping cart ...
fombo's user avatar
  • 11
0 votes
1 answer
81 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"...
Wayne Foster's user avatar
0 votes
1 answer
73 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 ...
rudolfbyker's user avatar
0 votes
0 answers
96 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 ...
user108001's user avatar
2 votes
2 answers
304 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 ...
Stephen Ash's user avatar
2 votes
2 answers
232 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. ...
quantumized's user avatar
  • 1,123
0 votes
2 answers
142 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 ...
Steve's user avatar
  • 349
2 votes
1 answer
257 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'])){ $...
quantumized's user avatar
  • 1,123
0 votes
1 answer
161 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 ...
Anton's user avatar
  • 273
1 vote
1 answer
316 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 ? ...
lobafox's user avatar
  • 99
0 votes
1 answer
358 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 ...
Lambic's user avatar
  • 744
1 vote
0 answers
93 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 ...
anoopjohn's user avatar
  • 908
1 vote
1 answer
152 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 ...
Kevin's user avatar
  • 27.3k
0 votes
1 answer
133 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 ...
berlindave's user avatar
0 votes
1 answer
66 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
97 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' =&...
alberto56's user avatar
  • 204
0 votes
2 answers
288 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 ...
liquidcms's user avatar
  • 1,135
-3 votes
1 answer
133 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 ...
NSp's user avatar
  • 1
1 vote
0 answers
57 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 ...
euphoricMV's user avatar
0 votes
0 answers
334 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 ...
C.A. Vuyk's user avatar
  • 227

1
2 3 4 5
29