Skip to main content

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
1 answer
235 views

How many state keys are too many?

The Drupal Core release 10.3 has a change in settings files, which recommends state_cache to be set to true unless there are too many. If it's not set, this is the message that shows up in Status ...
Adrained's user avatar
  • 349
0 votes
0 answers
65 views

How add a cache context in a form_alter?

I'm on Drupal 10.2.x. I'm writing a form_alter for a node add/edit form, where I am putting some extra markup data depending on terms of a vocabulary licenses. function my_module_form_alter(&$form,...
Giuseppe's user avatar
  • 981
0 votes
1 answer
111 views

Is there a way to remove cache tags from a render array

When I turn on cache debugging, I see a lot of cache tags for render arrays that don’t make sense. I don’t see an obvious way to remove these cache tags. For example, they don’t seem to appear in the $...
miwayha's user avatar
  • 31
0 votes
1 answer
65 views

How to disable caching of _custom_access callback

My module has several pages which use a custom access callback. The conditions for access may change from call to call so this needs to be checked every time. When I am logged in, the access ...
Kevin Finkenbinder's user avatar
0 votes
1 answer
106 views

How to disable cache in my custom contextual filter code?

I have created a custom module for authentication by using access_token. The authentication is working fine. So, I thought to create a custom contextual filter and use that as a filter by access token....
Selvakumar Eswaran's user avatar
0 votes
0 answers
17 views

How to make access check to be called once for all languages ​or its result is at least cached for all languages ​at the same time?

I have custom access check for custom entity: public function access(AccountInterface $account, Route $route, ?EntityInterface $product = NULL) { $requirement = $route->getRequirement('...
Pablo's user avatar
  • 1
0 votes
0 answers
109 views

How can I ensure the JSON:API response is using the most up-to-date revisions of my content?

I am working on getting gatsby-source-drupal set up in order to use the useStaticQuery hook for some content on my site. From what I understand, I need to use the JSON API instead of Drupal views to ...
Amy's user avatar
  • 21
1 vote
0 answers
93 views

Missing cache context from local tabs

As title suggest local tasks by default adds "route" cache context but my client somehow avoided it. All tabs on all pages looks the same. I am struggling to recreate this issue and I ...
Davor Horvacki's user avatar
2 votes
2 answers
173 views

How can I invalidate the entire cache when saving menu item?

I use the Simplify Menu module. Since changes in the menu are not applied, I would like to clear the entire cache. Unfortunately the following code does not work function ...
Joe Fred's user avatar
0 votes
1 answer
77 views

Adding response headers to media response

I have a custom module which implements hook_ENTITY_TYPE_access to control access to particular PDFs (media objects). When the user doesn't have access they are redirected to a login/register page. ...
Chris's user avatar
  • 1
2 votes
2 answers
383 views

How to hide CKEditor5 toolbar plugin based on user permissions?

I am using Drupal 10, CKEditor5, and a text format that has a good number of options in the toolbar including the source editing plugin. I have a custom module that defines a custom permission that I ...
Jordan's user avatar
  • 49
0 votes
0 answers
45 views

Dynamic loading of javascript bypassing twig cache

I am trying to figure out the correct way to have a javascript library dynamically loaded with every page load. For example, consider the scenario where I want to let the user toggle whether or not ...
Jablalr's user avatar
1 vote
1 answer
159 views

Caching of entity UUID in a frontend form

I have a form which is displayed in the frontend, through which anonymous users can create nodes. For guest users, the pages are cached and with them apparently some part of the form. We recently ...
Johannes Freudendahl's user avatar
1 vote
1 answer
103 views

How can I rebuild the cache for a specific route when a node of type foo is updated?

I created a page by a module and the cache of that page must be deleted if a node of node-type 'foo' is updated. How do I do that? I read https://www.drupal.org/docs/drupal-apis/cache-api/cache-tags ...
tis's user avatar
  • 75
1 vote
0 answers
99 views

Disable custom module Block Caching or force correct caching

I have build a custom module that builds out a list of child page links based on 'this' page's id. Logged in it works as expected. But an anon user has problems which range from the block not showing ...
ice70's user avatar
  • 131
1 vote
0 answers
169 views

Issues using placeholdering + bigpipe with varnish and CDN for personalised block based on IP

My use case is to show a block of recommended nodes on a node page. This should be personalized by IP address, so if someone's IP address indicates they are from x location show them y block and vice ...
chap's user avatar
  • 357
1 vote
0 answers
128 views

Unclear what the Redis "Render cache entries with most variations " means in the Redis report

We've recently started using Redis, and the report page shows a "Render cache entries with most variations" list. I've got about a dozen items that look like this: entity_view:block:...
zip_000's user avatar
  • 11
1 vote
2 answers
562 views

Why can't I disable CSS caching?

Background I am developing a custom theme for my Drupal 10 site. I found myself constantly flushing the cache, so I have been looking up ways to disable the cache on my local dev site. My end goal is ...
GeorgeCiesinski's user avatar
0 votes
0 answers
42 views

Does disabling the Drupal cache also disable the CSS Cache? [duplicate]

I am having trouble disabling caching in Drupal 10. To be more specific, I am trying to disable the cache using the Admin interface so that I don't have to manually edit any files in case I ...
GeorgeCiesinski's user avatar
2 votes
0 answers
226 views

Need help understanding caching issue on Pantheon and Redis

On a Drupal 9.5 site on Pantehon that uses Redis, we have Drupal cache and the BigPipe module enabled. The problem is that the cache is only being "hit" (?) if the same user visits a page ...
quantumized's user avatar
  • 1,239
2 votes
0 answers
129 views

Why does Redis show the top most invalidated tags as all "config.system.menu-***" items>

Drupal 9.5 - Redis on Pantheon. We are stuggling with site performance and I see that the Most Invalidated Redis Cache Tags are all super high. This can't be normal, right? Any ideas on how to resolve ...
quantumized's user avatar
  • 1,239
-1 votes
1 answer
101 views

Using common database for multiple developers in local environment gets slow

When use the common database to develop in local environment for multiple developers in one Drupal 9 project is getting too slow. This issue occurs on Drupal sites only, others (Wordpress, Laravel, ...
Sukanya Sathyan's user avatar
0 votes
2 answers
116 views

Set cacheability on a custom route returning XML

I'm working on fixing a custom module that returns XML from a certain route. Essentially what is described in the answers of this question. Currently this route isn't being cached. I've tried to ...
Vecta's user avatar
  • 603
0 votes
0 answers
31 views

Parent render cache not clearing on child node update [duplicate]

I have content types Parent and Child. Parent is a referenced entity in Child. My Parent template lists all children with reference to this parent. After updating the parents referenced in a Child ...
rhy's user avatar
  • 1
0 votes
1 answer
1k views

Why is the Cache-Control always "no-cache" and "X-Drupal-Dynamic-Cache" UNCACHEABLE on this site?

I have a production website for quite a long time now. By digging, we found that the Cache-Control was always to "no-cache" and "X-Drupal-Dynamic-Cache" is UNCACHEABLE My settings....
lobafox's user avatar
  • 123
0 votes
1 answer
106 views

How can I prevent a specific node type from caching for anonymous users (when using hook_node_access)?

I am using hook_node_access to decide the whether a node should be visible to anonymous users based on their IP address. To prevent this being cached I am using \Drupal::service('...
jofitz's user avatar
  • 135
1 vote
0 answers
101 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
  • 526
1 vote
1 answer
152 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
355 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
1 answer
760 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
  • 123
0 votes
1 answer
122 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
52 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
63 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
91 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
  • 539
2 votes
1 answer
376 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
1k 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('...
Amy's user avatar
  • 5,738
0 votes
0 answers
95 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
237 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
183 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
123 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
165 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
87 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
  • 542
2 votes
1 answer
916 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
112 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 ...
Sidney Sousa's user avatar
1 vote
0 answers
161 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
56 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
588 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
2 answers
2k 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
254 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
  • 487
0 votes
0 answers
94 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

1
2 3 4 5
29