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
2answers
597 views

Drupal 8 block cache

I created a simple block where it shows good evening or good afternoon depending on the time. But the problem is that i have to delete the cache otherwise it will stay at good evening ... How do i ...
0
votes
2answers
829 views

How bad is it to use Node_load in a loop in drupal 7?

Something like: for ($i = 0; $i < 100; $i++) { $node = node_load($i); print $node->fieldYouWant; } That is a lot easier to read, gives you access to all the fields etc. However, in a ...
12
votes
5answers
6k views

Which tables should be emptied when clearing database-stored cache manually?

Prior to D8 to clear cache manually one could truncate all tables beginning with cache_. In Drupal 8 there are still tables starting with cache_, but there's also a cachetags table. Is the advice in ...
7
votes
2answers
5k views

Stop caching for a specific node type Drupal 7

I'm working with a node type that has several custom fields. The values of these fields need to refresh on each page load, but because of Drupal's caching feature, they don't. What is the best way (...
6
votes
1answer
2k views

Meaning of “Query results” and “Rendered output” in Views cache?

Previously I've set the "Query results" and "Rendered output" cache to 1 hour. What I need is: Cache for 1 hour Update the cache immediately when related node updated But when updating node, it ...
5
votes
3answers
9k views

Flush cache of individual node when updated?

Is there any way to have an individual node's cache flushed if it gets updated? (instead of having to flush drupal's entire cache to show the changes to anonymous users immediately? (Rules or a module ...
4
votes
1answer
1k views

Disable caching for custom entity

I have set up access to some custom data by creating ContentEntity classes in my module, so I can query and display that data through Drupal entities. However, that data is also updated by a non-...
4
votes
3answers
2k views

Clearing local tasks cache

Using a deriver, I'm able to produce local tasks for each entity of my custom configuration entity type. So if I have two configuration entity labeled "Foo" and "Bar", I can have similarly labeled ...
4
votes
6answers
2k views

How to prevent Autocomplete Caching?

I have made textfield to be autocomplete field by using hook_form_alter. mymoudle_form_alter(&$form, &$form_state, $form_id){ $form['field_state']['und'][0]['value']['#autocomplete_path'] =...
4
votes
1answer
559 views

How to handle cache metadata in a cacheable response?

I have a custom controller action that returns the HTML for a search result. The action is invoked via AJAX on the search page and the results are inserted into the page body. The problem is that a ...
3
votes
1answer
389 views

Authcache vulnerabilities?

In my experience Authcache gives a great enhancement to performance, however I am wondering what are the potential vulnerabilities using authcache and boost together? My worry is that when the ...
3
votes
5answers
4k views

View page displays “Page not found” error but previously worked

I am working on a site at the moment with a View of "properties". The view used to function perfectly but for some reason now displays a "Page not found" error when trying to access the page and ...
3
votes
2answers
3k views

Caching pages for anonymous users prevents other cache logic?

I'm looking to confirm my suspicions as anything but, if I enable caching for anonymous users then any cache logic I've implemented in custom modules, views and blocks is thrown out, is this correct? ...
3
votes
1answer
1k views

Invalidate node cache so hook_node_view() runs on each node view

My module uses hook_node_view() to add some contents to the node view. function example_node_view() { if ($view_mode == 'full' && $node->bundle() == 'example') // Insert file listing ...
3
votes
1answer
3k views

Block: DRUPAL_NO_CACHE not working

I have a block that displays an item fetched from the database at random. The block has DRUPAL_NO_CACHE as cache parameter. However, when visiting the page as anonymous user with the cache on, the ...
3
votes
3answers
3k views

How to tell if a view gets cached?

I assume that as soon as you add a contextual filter, that is not a fixed value, the View becomes uncachable since it becomes dynamic, right? Is there a clear cut way to tell if the View gets cached ...
3
votes
2answers
2k views

Breadcrumbs are cached

In Drupal 8, if I create a node, add a menu link, save it, then go back and edit the menu link title in the node, the breadcrumb title does not update until I clear the cache. How can this be set so ...
3
votes
3answers
3k views

Clear views cache after node inserted in Drupal 7

I've views which list the list of node details. I've set views cache for 30 mins. I want to clear particular views cache when insert a node. I've tried below code to clear cache but there is no ...
3
votes
1answer
2k views

Content encoding error after enabling cache, aggregation and compression

Yesterday I turned on caching, aggregation of css and js files and turned on compress cached pages. Then I logged out and closed my browser (FF). After a couple of minutes I openend my browser again, ...
2
votes
3answers
778 views

Caching - techniques? suggestions? best practices? [closed]

I have a website that will be using three (3) views slideshows on the landing page/front page. What are the best ways to set this up site to be able to load efficiently? Should I start with a ...
2
votes
1answer
903 views

cache_menu items are huge [closed]

Drupal 7.24 I have been stonewalled by an interesting problem on a D7 site. Essentially the cache_menu table was getting very large but not just in items (6300 odd) some of the items are enormous. ...
2
votes
1answer
604 views

How do I add a cachebreaker to a specific image style in drupal 7?

I have one image style on my site that I need to add a cache breaker to. Ideally I just want to add . '#' . time() to the end of the src URL. For instance everywhere the large style is shown the ...
2
votes
1answer
800 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 ...
2
votes
1answer
926 views

Disable form or block cache for anonymous users?

I have two forms in Drupal 8 that I am prepopulating values with if a value exists in the query string. $keywords = Xss::filter($this->requestStack->getCurrentRequest()->get('keywords')); $...
2
votes
2answers
5k views

How and where to create a prefix key for memcache?

I am up to here in drupal documentation : Start at least one instance of memcached on your server. Edit settings.php to make memcache the default cache class, for example: $conf['...
2
votes
0answers
207 views

Drupal 6 APC with domain access module not working for (sub-)domains

I've recently enabled APC in my environment and using it with cache backport and APC beta 7.x-1.0beta3 which is a backported version for D6 modules respectively in site running drupal 6.22 which uses [...
2
votes
1answer
120 views

Updating cached REST resources

I'm building my first custom REST resources. I have a custom entity and returning specific fields from it. However, it's very important that if a specific field changes (a status field) that it is ...
2
votes
2answers
1k views

Aggregated CSS/JS file names, when regenerated?

What triggers the aggregated/compressed CSS/JS file names to be regenerated? Because of the default header for .css and .js set in Drupal's stock .htaccess is 2 weeks, this causes issues with Varnish ...
2
votes
2answers
956 views

How to invalidate cache contexts?

When updating my module from Drupal 7 to 8 I bumped into the concept of cache tags and cache contexts. After reading both documentation pages, I have come to the following conclusions: A cache tag is ...
2
votes
1answer
1k views

Need to flush cache after node translation

I have a Drupal 6 site running with multi language support. When I translate a node and get redirected to the newly translated node only the headline is visible. If I flush the cache using the ...
2
votes
2answers
1k views

cache_render database table growing in size

I am having a drupal 8 website where cache_render table is growing to GBs. I am not sure why this growing huge, any starting pointers would be helpful. Thanks
1
vote
2answers
2k views

Can't disable css caching and aggregation

I've recently installed some modules including wysiyg, ckeditor, ajax comment, b2 nice comments. I then noticed that my css files became cached and aggregated when inspect my pages. I unistalled all ...
1
vote
4answers
1k views

How to disable/enable cache of all views programmatically?

Case: I have over 50 views in my site and for performance improvement all were enabled to cache data during their implementation. Now I want to disable cache for all views at once for some reason (...
1
vote
1answer
391 views

How to avoid caching of fields in Entity View?

I have a few computed fields on my entity and they have dynamic values. These values cannot be cached because they change often. I've created the necessary field formatter that uses the same approach ...
1
vote
1answer
139 views

How to tell if an image was updated

I'm using images generated by Drupal (drupal 7) to feed an application. I'm then caching those images in the app. I'm trying to figure out a way to determine if the image has been updated since the ...
1
vote
2answers
2k views

How to disable/turn-off drupal 7 caching permanently, to not to mess with module's operations?

I am using Drupal 7 for a real time web application so I cannot afford any caching at all. I also could not find any such option in performance section of Admin Panel. Kindly suggest a method with ...
1
vote
3answers
1k 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; }...
1
vote
1answer
239 views

How can I force a view page not to be cached?

I created a few views which I use as JSON endpoints for a client application. However, they are not refreshed along with the content they serve. What I have tried with no success: Setting Caching to ...
1
vote
1answer
403 views

Caching pages with boost based on a cookie value

I have a Drupal website where a part of each page varies depending on the value of a certain cookie. In order to use Boost in this situation, I was thinking of rewriting the cookie value into a query ...
1
vote
2answers
851 views

Caching of blocks for anonymous user

I have a little probleme with my cache block. This is my build function : return [ '#markup' => time(), '#cache' => [ 'max-age' => 10 ] ]; I found this specification for block ...
1
vote
1answer
963 views

Drush cache clear corrupting database?

I just moved to a new computer: Windows 10 with XAMPP. As far as I know I set everything up the same as it was on my old Windows 7 computer. But now, for some reason, much of the time when I run drush ...
1
vote
1answer
107 views

Drupal 8 block cacheing

I have written a block, displayed on the right sidebar of my drupal 8 site. It reads the database, and shows today's reports. But the block's output is aggressively cached, so that it never shows the ...
1
vote
2answers
2k views

Is it possible to leverage browser caching?

I have ran a site through Google Page speed insights and one of its recommendations is to leverage browser caching for https://www.google-analytics.com/analytics.js. Is this possible on a Drupal site?...
1
vote
1answer
2k views

Do not cache custom block

I have a custom block created in code. I do not want to cache the block. I know I need to use BLOCK_NO_CACHE but I am not sure where to use it. function mymod_block($op = 'list', $delta = 0) { // ...
1
vote
1answer
869 views

How to define a new cache context for a node

I am preprocessing a node with some data, i want to define a new cache context based on this data. function hook_preprocess_node(&$variables) { $variables['change'] = rand(0,5); } Once i ...
0
votes
3answers
371 views

Custom Block Can't Invalid the Cache

I wrote a block in Drupal 8 to render a menu based on the http headers of the request, which contains the users' information from the idp. This menu is supposed to be different from user to user, but ...
0
votes
1answer
2k views

Why is “drush cc all” failing with “undefined function user_load()”

After updating my Drupal test server to have a fresh copy of the database and code from the production system, "drush cc all" would fail with a message saying PHP Fatal error: Call to undefined ...
0
votes
1answer
479 views

Block in Drupal 8

I have coded a plugin in my module which extends block base and generates labels for block in /admin/structure/block page under Place block. These block are being generated for different entities. The ...
0
votes
1answer
266 views

Has the Block Cache Settings from Drupal 8 been back-ported to Drupal 7?

I noticed in Drupal 8 there are options to cache a block: I was wondering if these options exist in Drupal 7 with a module? Has the feature been back ported? or was it a contrib module to begin with?
0
votes
1answer
50 views

Impossible to edit nodes, log to in etcetera after enabling Boost and editing .htaccess

After installing and enabling Boost in my Drupal 7 site (locally on WAMP and I also tried it on a remote test site) it's not possible to send any forms, e.g. not possible to edit and save nodes, not ...