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

How can I disable the cache for a specific page or have the cache ignore query params?

I need to disable the cache for a specific page, or get the cache to ignore query params. I have tried this, but it does not disable the cache for me https://www.drupal.org/project/...
-2
votes
1answer
42 views

Clear render cache with Rules [closed]

In Drupal 8, I want, every time I publish a node, to clear render cache. I have a Cover image in the homepage from a custom module, that doesn't follow the caching defaults as the rest of the site. I ...
0
votes
0answers
14 views

Boost cache files are not regenerating after they expired

We are using Boost static page caching for a website. Cache files are generating when we visit the pages first time. Then after that it never regenerate even after the expiration time is over. Cache ...
0
votes
0answers
23 views

How to stop spiders from crawling every combination of multiple drop-down pages

We have a site with around 10,000 pages and media items (mainly PDFs) We use various tools to catalog, check and report on our site and, of course we encourage good spiders (Google et al.). The ...
0
votes
1answer
30 views

How can I reset render cache on an entity for current user in hook_entity_view_alter()?

I have Commerce products for which I'm showing or hiding the add-to-cart link, if that product is or isn't in the current cart. In my code: function mymodule_commerce_product_view_alter(array &$...
0
votes
0answers
19 views

Multi site Image cache issue

actually i am new to drupal and i have migrated my drupal site from 8 to 9. This site is multi site, every thing is working fine but the issue is related to the images. When i cleared the cache using ...
0
votes
1answer
78 views

How to cache a view for all users of a role?

I have a view that displays a map. I need to display 7000 entries on the map. I have installed solar search API to index the content and have created a view using that. Still, the loading time for ...
2
votes
1answer
70 views

How to programmatically print a webform block with caching enabled?

When displaying a Webform inside a normal block (using admin/structure/block) Drupal manage to correctly cache the page, the HTTP header displays X-Drupal-Dynamic-Cache: HIT. However we need to ...
0
votes
0answers
45 views

Pages intermittently or randomly end up in 404

My drupal website is running on acquia cloud behind cloudflare. And there are there levels of cache avaialble. Cloudflare Acquia Varnish Drupal cache All these caches are set to expire after 5 mins. ...
0
votes
1answer
153 views

How can I prevent one template from displaying cached values?

I have a site with Drupal 8.9 and Twig Tweak. I created 7 view blocks to set up a task list in stores. I want to display a task counter for my current user on my home page. The tasks checks : If the ...
0
votes
0answers
34 views

Varnish isn't caching any page

I have a Docksal stack that includes Varnish (with the acquia Docksal stack). I made a static HTML page in the docroot, and Varnish is caching it, as shown by the HTTP headers: $ curl -IL http://...
1
vote
0answers
48 views

Logged in users are automatically logged out when visiting some specific pages

I have a page view /all-authors where both (Anonymous & Authenticated) users have access to it; However, authenticated users can follow (flag) an author and Anonymous users cannot do that. What I ...
1
vote
1answer
47 views

Change field access per user

I am trying to customize the access of user fields. We have an internal list of all users, which all members can access (for things like mail/address/phone number). However, due to privacy, each user ...
0
votes
1answer
47 views

why do my cache entries all double up with a #cache_redirect item?

I'm caching a piece of render array by adding cache keys to it. It's getting cached correctly, but I see two rows for every instance of it. One looks normal -- contains the render array, with a cid ...
0
votes
0answers
65 views

How do I make the cache smaller?

After we deployed our website to production, the number of users is big, so the cache size is also too big (30 GB); I believe its created per user per page. Our website for now only contains public ...
0
votes
0answers
37 views

Not able to load data from cookies until I clear cache [duplicate]

In my Drupal application, I have set some cookies through a javascript onClick method. However, am not able to access the data until I clear the cache(admin/config/development/performance/clear ...
0
votes
1answer
23 views

How do I define the default cache and cache settings programmically in a Kernel test?

A user provided a set of site caching configuration settings that cause some errors. For example: $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache'; $settings['cache']['bins'...
0
votes
1answer
37 views

Custom module interfering with CSS on /user page

I am having trouble with a custom module. When my site is working properly, the /user page loads 4 CSS files. After rebuilding the cache, only three files load. It's not a 404, Drupal doesn't even try ...
0
votes
1answer
78 views

Bypassing internal cache via query parameter

I'm attempting to bypass drupal's internal page cache and dynamic cache when a given url parameter is in a URL (as an anonymous user). The page in question is a view, and occasionally, when a user ...
1
vote
1answer
65 views

How to handle the cache per user in REST Resource?

I have a requirement to expose a specific content type data via REST end point. Below is my code: public function get() { $current_user = $this->currentUser->id(); $user = $this->...
1
vote
1answer
78 views

why Cache-tags is different if i am logged?

I try to understand how drupal core cache tags is add : this is my tags on my home when i am logged : node:121 node:158 node:23945 node:23946 node:43328 node:491 node:514 node:59139 It's good, ...
3
votes
1answer
140 views

How can I share cache with multiple users and roles?

In my custom module, I define a custom block that performs an expensive operation: /** * {@inheritdoc} */ public function build() { $data = get_expensive_data(); $agent_number = ...
1
vote
1answer
45 views

Clearing Twig cache only?

We have this large website where we would have to deploy html changes in Twig quite often. I'm looking for a solution to clear the Twig cache ONLY. So we do not have to do a general cache rebuild, ...
0
votes
0answers
47 views

how to add only modify cache-tags to purger queue on node save?

I have the purger module installed, when i edit a node and save it without change anything, this is what i see in the purger queue : Is it possible to alter the way to add tags in the purger queue ? ...
1
vote
1answer
50 views

Invalidate cache on ConfigFormBase submit

I have a ConfigFormBase called TextConfiguration where I have defined several fields for the address, phone number, etc... These variables are shown in the contact form on my website. When I modify ...
1
vote
0answers
54 views

How to setup 'headers' cache context by value?

I try to set a headers cache context (/core/lib/Drupal/Core/Cache/Context/HeadersCacheContext.php) by the value of a custom HTTP header. My web server sends a custom HTTP header X-My-Custom-Header. ...
1
vote
0answers
51 views

When I clear cache, my menu ordering seems to go out of order

When I clear cache, especially on high traffic times, my menu seems to go out of ordering. Usually I don't see any log messages except for one time: Message Drupal\Core\Database\...
0
votes
0answers
13 views

how cache a view, that has a field that is calculated with php code [duplicate]

//source code from simple_hierarchical select node count module function shs_node_count_term_get_node_count function count_term_get_node_count($term, $count_children = true ) { $og_group_ref = ...
0
votes
1answer
37 views

how cache a view that has a field that is calculated on the fly

in a view, one field has the following computed value, which takes a lot of time to return results from the database: <?php $term = taxonomy_term_load($data->tid); print ...
1
vote
1answer
68 views

How do I disable cache in my entityQuery?

I created a preprocess function in my recipe node page, inside that function I want to get 3 random recipes everytime the user accessess the page. I have this code: function ...
1
vote
1answer
85 views

{{ drupal_view('view1', 'block_2') }} renders only when cache is cleared

I like to output 2 block-views in a template called "block--bar.html.twig", but only when i clear the cache they are printed. (i installed Twig Tweak 8.x-2.x) This is the template: <section{{ ...
0
votes
1answer
43 views

Disable cache on base url for redirecting unauthenticated users

I am trying to redirect unauthenticated users. So anytime an unauthenticated user tries to get to the base url, redirect them to an external url. Currently works, but continues to redirect to the ...
0
votes
0answers
16 views

Whats the file structure and correct implementation of using StackMiddlware for a redirection? [duplicate]

I'm currently using an EventSubscriber to successfully redirect unauthenticated users from my site. However, the redirection still takes place on that specific page even after the user is logged in ...
2
votes
0answers
71 views

How to implement StackMiddleware for a redirection correctly?

I'm working on a redirection (for unauthenticated users) for my Drupal 8 site. Currently, the redirection works however, the redirection persists even after user is authenticated. I found this article ...
1
vote
0answers
51 views

How to make EventSubscriber run on every page load? [duplicate]

Tripped up on how to make my EventSubscriber code run on every page load. In my src/EventSubscriber/RedirectAnonymousSubscriber.php file here's my code: <?php namespace Drupal\mymodule\...
0
votes
0answers
32 views

Cache Contexts in Entity Definition Doesnt seem to do anything

I have been using jsonapi to query my own custom entity and I've encountered a strange bug: When a user that has access to the entities does a get request at the json:api resource the results get ...
0
votes
0answers
26 views

Drupal Site Migration from FreeBSD 12 to Ubuntu 18.04 SQL database unknown behavior

I am currently trying to migrate the Drupal Site from FreeBSD 12 to Ubuntu 18.04. All the configurations are copied and moved to Ubuntu 18.04. Everything seems fine and I was able to create the Drupal ...
4
votes
2answers
172 views

What is the correct way to update my cached block when a node of a given type is saved or updated?

I have a custom module with a block plugin: SliderBlock.php class SliderBlock extends BlockBase { public function build() { $build = []; $build['#theme'] = 'slider_block'; return $...
0
votes
0answers
14 views

Custom views filter plugin: cachetags invalidation does not effect option list

I described a custom views filter plugin extending InOperator. The aim is to offer a select list where the user can choose from a list of fractions of a legislature. Legislature and fractions are ...
0
votes
1answer
79 views

Cache a block by a custom entity rendered within

I struggle with getting a custom block cached correctly: we have a custom entity "Politician" For that entity we have several routes where we want to render a "politician header" with some basic ...
0
votes
0answers
67 views

Variables in drupalSettings get cached

I am using the value of a field in the page as a variable. I am trying to use it in the page somewhere else but I think that there is a problem with the cache because the value is sometimes available ...
0
votes
1answer
36 views

Best practice caching a variable between page loads [closed]

In Drupal 7... In the case of a value that is only set through a module's settings page, and then remains unchanged until an administrator changes it (or the module is updated). The value is checked ...
0
votes
0answers
49 views

Bypassing page cache for Drupal events

I need some session verification code to be run on each request to Drupal. The most obvious solution that I have found was to use the EventSubscriber interface, and the KernelEvents::REQUEST event. ...
0
votes
0answers
37 views

How do you cache a menu when loading it programmatically?

I am having the below code to load the main menu tree. $tree = menu_tree_all_data('main-menu'); $parentMenu = array(); $index = 0; foreach($tree as $key => $value) { if (!empty($value['...
0
votes
1answer
53 views

Excerpt of Search API index is cached

I'm using the search_api extension (V 8.x-1.14) with the Database search (no solr, etc.) I use the search block which is created by the search view (/search path) I want to show the highlighted ...
0
votes
2answers
194 views

Invalidating Paragraph Cache

I'm working on a paragraph type that will need to display on a very limited number of pages but has some specific functionality where the preprocess function will need to run each time. In my ...
1
vote
1answer
249 views

Problem setting user specific cache tags on custom block with user context

I have a simple custom block with a user cache context and a specific user specific cache tag: /** * Provides a 'User example' block. * * @Block( * id = "user_example_block", * admin_label = ...
1
vote
3answers
179 views

Database deadlock detected

On Drupal 8 we're getting a few deadlock conditions - most connected with the cache. There are quite a few answers to this issue but not so much for D8 (which has very different caching mechanism). Is ...
0
votes
1answer
73 views

What is x-speed-cache-key? What is its purpose?

Our drupal site was pentested. The pentest report labeled an action involving the header X-Speed-Cache-Key as a security concern. The finding stated: Arbitrary parameters supplied to the query ...
0
votes
1answer
140 views

Event subscriber to invalidate a cache

I am invalidating a cache tag in KernelEvents::REQUEST event: public static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = ['onRequest', 100]; return $events; } public ...

1
2 3 4 5
27