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
3
votes
1answer
239 views

Custom placeholder markup when leveraging #lazy_builder in elements

Using bigpipe. To avoid blocking page loads for long-lasting API calls, etc, I implement: $element = [ '#lazy_builder' => ['service.admin:method', []], '#create_placeholder' => TRUE, ]; ...
0
votes
0answers
13 views

safely empty all drupal cache in SQL [duplicate]

what tables related to drupal cache can be safely delete using SQL and how to be sure to empty it entirely? It seems i have reminiscence of ancien block configuration when i empty cache using back ...
2
votes
0answers
2k views

How to properly cache AJAX request responses with the controller from my custom module?

I've got an drupal 8 project with an custom module. There I have an controller which returns specific data we need there. In my js file, I have 7 AJAX requests which are called when someone visits the ...
0
votes
2answers
385 views

Drupal 8 Page Cache

I am using dynamic tokens in page title, which is always being cached. I want to stop that. I have try by disabling page cache using function hook_preprocess_page(&$vars) { $vars['#cache']['...
1
vote
1answer
365 views

Can I get Entity Cache Tags from a Route?

If I have a node object I can use $node->getCacheTags() to get the cache tags for the node object, and I can do the same for other entities. Is there a way for me to do something similar with a ...
1
vote
1answer
153 views

How to debug an empty cache_page table

I have a bunch of sites built off the same profile, and recently noticed the pages aren't being cached. I spent some time doing the usual: looking for drupal_set_message calls, disabling all the ...
2
votes
1answer
418 views

Prevent Drupal from Caching API Responses

I am not sure this is even supposed to happen, but it looks like Drupal is caching REST API responses. I have created a module that makes certain data available through the REST API, and changing the ...
1
vote
0answers
87 views

Does Drupal Cache work with views rendered programatically?

I want to understand does the Drupal caching work for views which are called programmatically I am using views_get_view for my implementation plus hook_views_query_alter to further add a where ...
0
votes
1answer
222 views

D8 - Entity Load Cache

First of all. Are $ent = Drupal\custom_entity\Entity\MyEntity::load(1); and $ent = \Drupal::entityTypeManager()->getStorage('custom_entity')->load(1); the same? Also I know that \Drupal::...
2
votes
1answer
819 views

What's the equivalent of cache_clear_all()?

What's the equivalent of cache_clear_all() in Drupal 8?
0
votes
1answer
70 views

Page cache maximum age [closed]

Please advise me on the correct value to choose for “Page cache maximum age” as a cachin strategy (I’m running a medium Drupal 8.5.3 website).
0
votes
0answers
25 views

Images and styling not rendered correctly on page refresh

The problem is that images and some styles are not correctly rendered when I hit Cmd+R and doing a refresh, but it is working fine on a reload. So my question is not what the difference between a ...
3
votes
2answers
930 views

Invalidate Internal Page Cache on cookie change

I need to invalidate the Internal Page Cache for anonymous users when the value of a specific cookie changes. How can I implement this? I'm tried to add: $build['#cache']['contexts'][] = 'cookies:my-...
0
votes
1answer
248 views

How to set different cache mobile and desktop based on header HTTP for one URL?

Here is the problem we're facing : I have one url : www.example.com/my-page with a different HTML footer for mobile and desktop. To know which HTML to use we look for HTTP Headers sent by one CDN (...
0
votes
0answers
134 views

Cache response json with on route

Why doesn't this cache anything? $cache = [ '#cache' => [ 'tags' => [ 'test' ], 'max-age' => -1 ] ]; $response = new CacheableJsonResponse($data, 200); $response->...
0
votes
1answer
62 views

Where is the module registry stored outside the database?

As a long time Drupal dev, I should probably know the answer to this question, but I'm stumped by the behavior I'm seeing. Let's say I have a local and a remote site. On the remote site a module is ...
0
votes
1answer
266 views

Clearing contextual links'cache

I'm listing nodes in a block view which is located in a panel managed by page_manager. I need for these nodes somes custom opérations in contextual links, so i implmented hook_contextual_links_alter(...
0
votes
1answer
38 views

Updating Node Field using drupal_write_record doesn't show changes until cache flush

Problem is in the title basically, I'm trying to update a specific field in my node and I have to do it by using drupal_write_record rather than loading and modifying the node object itself, or by ...
0
votes
2answers
30 views

How to clear CSS and Javascript with a bookmark?

I would like to clear the CSS and javascript in D7 with the help of a bookmark. Currently this is: <domein>/admin_menu/flush-cache/assets?token=<tokenid> This is working however the ...
2
votes
2answers
3k views

How to debug page caching?

I've got a page which returns X-Drupal-Dynamic-Cache: UNCACHEABLE, I've got a suspicion that this is related to a view that is embedded in the page. Though, this made me wonder; is there any way to ...
1
vote
0answers
523 views

Call to a member function getCacheTags() on null line 1630 of core/modules/views/src/Plugin/views/query/Sql.php [closed]

This error popped up a little while ago and we can't figure out what is causing it to be null or what needs to change. It is caused by a view that is set up as an rest api that you give it a NID. ...
0
votes
1answer
761 views

Using #cache key on a render array generates 2 entries per role, how to change that?

On a page controller I have a method that displays the content via a render array. It also caches the rendered output using the #cache key: public function viewContent(NodeInterface $node) { $...
2
votes
1answer
817 views

Does the #cache property for render arrays cache content from a query when used in a controller?

I have a custom page displaying a query result from the database. Before I attempt to cache it myself, I am trying to see if Drupal 8 render arrays support caching in anyway for authenticated users. ...
1
vote
0answers
592 views

How do I add CacheableMetadata to an array I'm returning in a rest resource?

I'm getting the following error, which I've seen in several other questions, but as yet I haven't been able to make any of the example solutions work: LogicException: "The controller result claims ...
0
votes
0answers
90 views

Caching problem: Why does the pager of my pages module not work?

I am using the pages module in combination with the view module on the front page of my website. This worked until recently, when my pager started to behave strangely. The pager does not work anymore ...
1
vote
3answers
1k views

Set custom cache expiration time for a block

When returning info for a custom block we can specify what kind of caching that will be used for the block according to the values in: hook_block_info(). Notice that if the block is cached the ...
0
votes
1answer
105 views

What happens with modules and themes when I rebuild the cache?

Just for learning, this document explains me in a "ballpark" way how cache rebuild works, but I want to know more about "Updates the system with latest information about extensions (modules and themes)...
1
vote
1answer
1k views

Drupal 8: “Page cache maximum age” is not working for anonymous users

I have set a page cache maximum age for anonymous users in Drupal 8, but it seems not to have any effects. Accesing the pages as an anonymous user, changes are visible immediately, and I can't see any ...
2
votes
1answer
175 views

Views Remember Last Selection Back Button D8

I am having trouble with "Remember last selection" on views in D8. If I click a link away from the view and click back it does not remember my last selection. If I then refresh the page it does. This ...
0
votes
1answer
26 views

Images break with wrong href; clearing caches fixes!

Occasionally we will have graphics in various places on the site that are missing because of incorrect hrefs with unknown subdomains and are fixed when the caches are cleared. So an incorrect link ...
0
votes
1answer
795 views

Varnish doesn't cache first hit at all, only second hit

I have Varnish 4 with Drupal 7. In Drupal settings.php I have: // Tell Drupal it's behind a proxy. $conf['reverse_proxy'] = TRUE; // Tell Drupal what addresses the proxy server(s) use. $conf['...
0
votes
0answers
205 views

D8 - Homepage Redirect gets cached

Is there any way to keep the redirect logic of the homepage uncached but to keep the page itself cached? I have a "location by ip" redirect on the "/". This logic then redirects to the correct ...
2
votes
2answers
5k views

Disable the cache for a specific view

I'm showing my users a random number ({{ random() }}) in a twig which is being rendered in a view. But when I refresh a page it just shows me the same number. I tried several things but they all ...
1
vote
1answer
278 views

Javascript translation broken - fixed after cache clear

I just encountered a problem with the javascript translation. I have a javascript file where I generate small UI elements using jQuery, and I wrap the label in the Drupal.t function. The site is ...
1
vote
1answer
1k views

Menu theme suggestion ignored when cache turned on

I have an alternative main menu that is used on specific node types. When turning on the cache the menu block is cached. The theme suggestion for the menu is then ignored. I tried to disable the menu ...
4
votes
2answers
878 views

How to set cache meta data on drupalSettings?

I use drupalSettings to send config data to javascript. But when I edit my config, the javascript object is not modified, I have to clear all cache to get the update. The cache metadata in http ...
2
votes
3answers
4k views

Disable caching on a custom plugin block

I read a lot of posts on how to disable caching on a custom block but none seemed to give the perfect solution. $build['#cache'] = ['max-age' => 0] or public function getCacheMaxAge() { return 0; }...
0
votes
1answer
106 views

When directly loading a Commerce 2 Order Item, why is the entity cached for anonymous users?

I'm using the following to load a Commerce 2 Order Item: $order_item = \Drupal\commerce_order\Entity\OrderItem::load($order_item_id); If I empty the cart for an anonymous user (thereby removing ...
5
votes
2answers
7k views

How do I invalidate the cache of an entity?

Is there any easy way to clear the cache for a custom entity? I know there is an entry in the cache_entity-Table. If i manually delete it, everything is fine. I tried doing the same as in \Drupal\Core\...
0
votes
1answer
1k views

$.cookie is not a function from form.js with block cache

I am getting this error if I turn my block caches on. I have traced back the origin back to Drupal core form.js but can't seem to see what's going on here. Any ideas? Here is the debug: form.js?v=7....
0
votes
1answer
221 views

Custom breadcrumbs from a breadcrumb builder disappear until I clear Varnish cache

Unrelated to this question, which is about how to properly inject breadcrumbs as a renderable item into a node template.. I have a custom breadcrumb builder for certain node types with the same sort ...
0
votes
1answer
56 views

Drupal 8 - Stock quote cache

I'm building a Drupal 8 site that has a stock quote on every page. The data for the quote comes from a database. The requirement is that the stock quote data be refreshed every five minutes and I've ...
0
votes
1answer
665 views

Error when get rest resource : The controller result claims to be providing relevant cache metadata

I try to create a REST resource. I used EntityResource as base. I would like to return my fields in html. Here is a exemple of my code : public function get($id) { if (!$this->currentUser-&...
1
vote
2answers
1k views

Cache for logged-in user?

I have created simple form and page to list records on form via Custom Drupal 8 Module. This form is accessible to only logged-in users with some specific role. It looks like screenshot. Whenever I ...
0
votes
0answers
371 views

Advagg only aggregating and compressing some files

I'm using the Advagg module to reduce the number of http requests for CSS/JS files, but this only seems to work to a limited extent. In particular I'm concerned about why my theme stylesheets/js aren'...
-1
votes
1answer
4k views

How to add version parameter to JS & CSS files to avoid browser cache? [closed]

What is the best way to append the file version number in order to give to the users the right JS/CSS files? Actually i am working on a website which has a browser cache expiration date set to 5 days....
1
vote
1answer
2k views

Cache rebuild causes an error with missing plugin

On rebuilding the cache, a Drupal 8 website goes down and displays the message "The website encountered an unexpected error. Please try again later." I used drush cr to rebuild the cache, which shows ...
0
votes
1answer
1k views

Disable Internal Page Cache And Enable Dynamic Page Caching

Can some one let me know how to disable internal page cache and enable dynamic page cache. And also how to enable and configure varnish or memcache in drupal. Can we enable and use both varnish and ...
0
votes
1answer
68 views

Hundreds of unserialize requests

I have a large Drupal 7 website on my hands that is very large and has loads of modules (over 200). I am already seeing poor performance symptoms in the FPM logs with max_children limits reached on ...
2
votes
1answer
1k views

Ignore cache in preprocess function

I have a content type 'homepage' containing one node which is used a the homepage. This node has a multivalue image field, and I need to randomly select one of those images to show on the homepage on ...

1
3 4
5
6 7
28