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
-2
votes
0answers
24 views

Disable footer cache

I have made menu links in footer region of Drupal 8 website. If i unpublish the basic page whose menu link is given in footer link, the link does not disappear until and unless i clear the cache from ...
0
votes
0answers
25 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
21 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 ...
-1
votes
0answers
47 views

How do I avoid Twig is cached? [duplicate]

The following code is used to display whether the users are online, absent, or offline. My problem is that the current date "timestamp" is cached, so there is no change in user status unless I ...
4
votes
2answers
153 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
12 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
68 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
33 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
35 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
41 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
34 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
21 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
59 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
75 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 = ...
0
votes
3answers
94 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
38 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
61 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 ...
0
votes
1answer
43 views

Disable cache a custom block for anonymous user

I have a custom block, it displays in every pages with dynamic data calculates in every refresh, How can I disable cache for this block for anonymous users? I try with: public function build() { ...
5
votes
1answer
67 views

Is there a way to partially rebuild the router or invalidate a route cache?

I'm using the Groups module (http://dgo.to/group) to set up groups on a SaaS project I'm working on. I've set up a domain field on the groups, allowing groups to have vanity domain. As such, groups ...
1
vote
0answers
78 views

Invalidate cache of views block for anonymous users

I have a view display block that needs to be updated every 8 hours. I tried Views Custom Cache Tag module https://www.drupal.org/project/views_custom_cache_tag but I could not make it work. I set my ...
1
vote
1answer
119 views

Cache-Control response header includes “private”

Why does a vanilla Drupal 8 site add cache-control: must-revalidate, no-cache, private to all the pages? A Drupal 7 site adds cache-control: must-revalidate, no-cache. Is that addition of private ...
1
vote
1answer
53 views

Preventing redirects from being cached for anonymous users

I have a content type that needs to redirect only when it is tagged as "External". All of these "External" items have a field where a URL is supplied for the redirect. During initial setup of the ...
0
votes
0answers
29 views

Invalidate local_task cache for a specific entity

Is there a way to invalidate local_task cache for a specific entity? The issue is that an additional local task is defined by a different module that has a custom access check. That custom check if ...
0
votes
0answers
39 views

Region with menu block disappears suddenly, re-appears after re-saving menu

We have a website with a menu in a block, that is placed into a region "Sidebar". My customer notified me that the whole region containing the menu keeps disappearing on the live site, on average once ...
0
votes
0answers
48 views

Caching based on roles

How would it be possible to unset the "Cache-Control: must-revalidate, no-cache, private" that drupal adds for logged in users, for a specific role? I want a specific role, to follow the non-...
2
votes
1answer
60 views

Have followed instructions to disable cache for development but it's still caching

I have followed all the instructions here https://www.drupal.org/node/2598914 I'm developing a module with a block, and when I went to the Block Layout page and clicked "Place Block", the list of ...
1
vote
2answers
294 views

How can I make a response cachable by browsers?

I am working on a Drupal Controller implementation that would return a generated image as response. I used Symfony's Response and I was trying to add ETag header to it: use Drupal\Core\Controller\...
3
votes
1answer
120 views

How can I let authenticated users rebuild caches?

Is there a way for authenticated users to clear the cache without giving them the administer site permission?
0
votes
1answer
98 views

How do I disable caching for the Forum module or, alternatively, how do I fix caching?

I use the normal standard Drupal Forum module with a clean Drupal 8 installation. After I have installed it, I have a problem where "2 new posts" shows for all users. In other words, the /forum page ...
1
vote
1answer
63 views

Cache pages/variables in hook_preprocess() for anonymous user

So I am having trouble understanding the caching of variables set in hook_preproccesses for anonymous users. It seems that the entire page is cached, and not rebuilt, even when set to no caching. With ...
0
votes
0answers
35 views

Caching user profile image? [duplicate]

If I log in as User 1, i see user 1's profile picture. If I log in as User 2, I see user 2's profile picture. As expected. But after browsing a bit, User 2 would suddenly see User 1's profile picture. ...
0
votes
1answer
30 views

How to update route cache when saving an entity?

I have added a custom access check to the /user/{user} route: class RouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $...
4
votes
1answer
96 views

How to deal with Bubbleable Metadata when there's no rendering context and no render array

Since Drupal 8.0.0-beta12 "all rendering must happen in a render context", as stated by this change record. This is to avoid bubbleable metadata lost. So far, so good. Let's say I'm implementing a ...
1
vote
2answers
86 views

WSOD while sending headers, probably Cache-related

I have a very strange problem with a fresh Drupal install: On some pages, I receive a WSOD with ERR_EMPTY_RESPONSE: It happens for instance when on admin/config/development/performance I click Clear ...
-2
votes
1answer
26 views

What is the use of page_cache_fastpath ? When and how should we implement it?

When I am debugging drupal, I came across the concept page_cache_fastpath. I want to know the use of it.
1
vote
1answer
61 views

Invalidate Internal Page Cache at certain times in a day for anonymous users

Let say I have a webshop open from 9am to 11am (data coming from config). When the shop is closed, I would like to display a message (shop closed) and when the shop is open, my commerce product should ...
0
votes
0answers
23 views

when one apache server got restarted, the website session seems lost intermittently

Our drupal website is hosted in AWS cloud platform clustered with three instances in additionally, we have two memcache servers and we are using memcache_storage module for caching. We have observed ...
0
votes
0answers
21 views

Can a cached query being used as another query select?

I've got a query as follows : $selected_services = array(512, 825, 912, 913, 936); $query = db_select('users', 'u'); $query->join('users_roles', 'ur', 'ur.uid = u.uid'); $query->join('role', '...
1
vote
1answer
85 views

Set parameter for internal or external traffic based on IP

We want to block external traffic in Google Tag Manager and I am trying to do something like shown here. I created this: /** * Implements hook_init(). */ function myfunction_init() { $...
0
votes
1answer
45 views

How to un-cache a specific node field (also for anonymous)

My goal is to replace (by a custom markup) the render array of field_product when some conditions are met. (in a ecommerce site) Ex: If this is the weekend or if it is after 12pm the field_product ...
0
votes
2answers
78 views

CSS changes not updating

Basic caching settings all off: settings.local.php is loaded: Bottom of settings.php: if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) { include $app_root . '/' . $...
0
votes
2answers
59 views

After save empty cache of referenced node

I have two content types. For clearer question I will work with the content types event and location. From my location content type I can reference to and event. Then on the event page I show the ...
0
votes
0answers
12 views

Redis server hang up when I update drupal

I´m not sure if this is the right place to put this question. I hope it be. I have an apache server with Redis and several Drupal 7 websites that uses Redis as cache backend. It works very good and ...
2
votes
1answer
70 views

Remove the cache for a particular Twig file

I'm showing the name of the currently logged-in user in header, using \Drupal::currentUser()->getUsername(), but it's showing an already cached page. I know I can disable the cache for a ...
0
votes
1answer
330 views

How can I purge a specific URL from varnish cache without making a curl request?

I'm programmatically updating images and keeping the same file name. I flush the image styles for the image when I do this, but I'm running into an issue where my image styles aren't being regenerated ...
0
votes
1answer
125 views

How do I enable the ETag header?

I'd like my JSON:API responses to return the e-tag header so that consuming remote sites can determine (e.g. with a HEAD request) if they need to ditch their cached responses and re-fetch. There is ...
0
votes
0answers
23 views

How to move js in header from footer in D8 [duplicate]

I am using twitter bootstrap theme in drupal 8. By default bootstrap.js and jquery.js loaded in footer. I want to override the order of these js and place in header. Please let me know if its ...
0
votes
0answers
42 views

Caching input filter results

I'm creating an input filter that is quite expensive, as it makes a call to a remote service as part of the processing of the output. In Drupal 7, I'm pretty sure that the filtered output of an input ...
2
votes
1answer
73 views

Why doesn't LinkFormatter::viewElements bubble cache metadata?

I am trying to understand how the token system in Drupal 8 interacts with the cache bubbling system and in LinkFormatter I see $link_title = \Drupal::token()->replace($item->title, [$entity->...
1
vote
1answer
84 views

Wrong User Image Display - Weird Twig Cache?

I'm having a weird issue with incorrect user images being displayed and it seems to be a caching issue or perhaps I am passing the user image incorrectly to my template. Problem: If I login to a ...