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
4
votes
1answer
415 views

posting a comment on cached page

I am a bit confused now - is it normal behavior that posting an anonymous comment on cached page invalidates ALL cached pages for whole site for current anonymous user? Beacouse that is exactly what I ...
3
votes
1answer
6k views

X-Drupal-Cache http header

Examining for http headers, I mentioned the header "X-Drupal-Cache HIT". I use varnish reverse proxy. Is it necessary for this header to appear? Can I make it be ommited? If yes, how? Would that have ...
12
votes
3answers
12k views

How to keep cache_form small

I have noticed in mysql that cache_form.MYD table is 14GB. Why did it grow so big? Is it safe to empty it? and how can I avoid this happening in the future? Thanks
10
votes
6answers
24k views

Clear Cache without logging in

I added an if statement around the content render php in my page.tpl.php file. Only problem is I made a mistake and accidentally prevented it from rendering content on any page. I cleared the cache ...
9
votes
2answers
6k views

Disable cache for specific blocks

I would like to let pages continue to benefit from Drupal 8 caching mechanism for anonymous users, except for a specific blocks which should update on every page refresh knowing that they are ...
8
votes
1answer
3k views

Where do I add a new cache context for an entity?

I have not been able to get adding a cache context to work for entities in drupal 8. Specifically I'm going for headers:User-Agent. I tried many variations on the following in a module. use ...
7
votes
3answers
6k views

How do I invalidate cache of an embedded view?

I have a node type "Article" that contains a repeating Paragraphs field. One of the paragraph types let's the user embed a view using a entity reference field. When rendering an Article node ...
4
votes
5answers
837 views

Which cache have to clear to update new hooks?

I added a new hook inside a module (hook_cart_commerce_pricecomponent_type_info_alter), which cache have to clear to only update that new hook? I mean i do not want to clear all caches. ...
4
votes
3answers
751 views

REST response gets cached for guest user requests

I've implemented kind of a page hit counter as REST request. The article page renders a JS into the page that does a jQuery.getJSON to the REST resource later. So far that works fine. The page is ...
3
votes
1answer
1k views

Can I change the location of the cached Twig templates?

By default, the Twig template cache appears to go into /files/php/twig. I was wondering if it's possible to change this location? I use a shared file mount which is shared between multiple developers ...
3
votes
0answers
645 views

Configuring Varnish for Drupal with Proper Module Usage (Expiration Cache, Varnish, Purge, Memcache)

Can someone help me straighten out my setup? What is needed...what isn't? Varnish has been working well with a high hitrate average, but I am really trying to dial in my configuration. Any insight ...
2
votes
1answer
4k views

Huge cache_menu table

My Drupal database becomes very huge, it just related to cache_menu table: ~4,291,529 rows and 2.9 GiB What can I do to prevent this? is there any way to change cache strategy for menu items? or ...
2
votes
2answers
1k views

Cache form Drupal change expire time

I made cache_form table work (see How to keep cache_form small). But cache_form, though expired cache is now cleared, is enormous anyway (nearly 2 Gb, and we have only 1000 unique users in a day). ...
5
votes
4answers
4k views

Is it mandatory to clear cache for each and every change made?

It takes more time to clear caches and it also needs to be done more frequently for the each CSS or functionality wise changes. Are there any alternatives available?
4
votes
2answers
3k views

How do you clear cache on a block when node of certain bundle added or updated?

If you want to clear cache on a render array when any node is updated you can add as a cache_tag, "node_list": '#cache' => [ 'tags' => ['node_list'] ], But there isn't a way to do this ...
4
votes
2answers
498 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 ...
4
votes
1answer
844 views

What does General Cache Wipe mean

The definition of CACHE_TEMPORARY used in cache_set reads as follows. CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe. I am just curious as to what ...
3
votes
5answers
3k views

Drupal 8: How do I invalidate cache for a block for anonymous users on a schedule?

At the top of every page of page of my organization's site resides the current hours of operation and current "now open"/"now closed" status, using Views block and Office Hours module). At this time ...
2
votes
1answer
143 views

Caching mysql results in cache table to be retrieved later

How can i fetch records from mysql results stored in cache table ? $cached_res_obj = cache_get("expensive_sql", MY_CACHE_TABLE); $res = $cached_res_obj->data; while ($row = ...
2
votes
1answer
826 views

Is using a TLS/SSL termination reverse proxy currently possible in Drupal 8

I use Nginx (port 443) which terminates TLS/SSL then forwards the request to Varnish (port 80) and on to Apache (port 8080). This worked really well for D7. Am I correct in thinking that because of ...
2
votes
2answers
5k views

How to disable cache for a specific content type?

I use Drupal 8 and I want to disable caching for a specific content type in full view mode. I've found how to disable caching for all view modes, but I want to disable it for only a specific content ...
2
votes
2answers
3k views

Varnish/Drupal caching for logged in users

Problem Varnish is caching pages when I go onto my website anonymously. I have "Cache Pages for anonymous users" turned on so this is expected. But when I login it continues to load the cached page ...
2
votes
1answer
5k views

Leverage browser caching issue [closed]

I added some lines in my .htaccess file, following Is it possible to leverage browser caching?, but Page speed tool still throws "Leverage browser caching error." for only images.
1
vote
2answers
2k views

How to set up APC on Drupal 7 with httpd + fastcgi?

Can you recommend how to set up APC for a site running Drupal 7 on apache2 with fastcgi ? I got to the point where apc.php shows only one file cached that is apc.php itself. I cannot see if APC cache ...
1
vote
2answers
671 views

How can I ensure a referenced entity is cached separately per paragraph?

I have a situation where two Paragraphs on single page may potentially reference the same entity. The affected paragraphs have a field to change their colour, and this colour value is passed down to ...
15
votes
9answers
7k views

Is there a way to hook on cache clearing?

For a big institution website, with heavy caches, I'd like to generate caches as soon as possible, so that no user may arrive on cache generation... I have a cron set all minutes that does it, by ...
8
votes
2answers
11k views

How to prevent caching of a page?

I've set a custom homepage url at example.com/welcome. The user comes to the example.com/ and logs in on that page. Drupal redirects to example.com/welcome Now the user clicks on the home page which ...
7
votes
5answers
2k views

How to rebuild a cached page when it expires?

I'm using views caching after reading this great Q&A and getting good results. I have to keep the expiration short because I'm showing the "last comment" in the view and those changes often. I'm ...
6
votes
1answer
802 views

How can I use the same render cache but for json?

I am working on REST API and I would really like to be able to use the same mechanism for responses as Drupal uses for cached content. Unfortunately there is no render cache, everything is JSON ...
5
votes
4answers
487 views

Installed Boost Caching, but now my dynamic blocks and webforms are also cached

I just installed Boost module for Drupal 7, but now my Webforms and dynamic blocks like commerce shopping cart block isn't working. It's most likely cached, but what are some methods of getting these ...
5
votes
4answers
2k views

How to get Views caching working with contextual filters?

Using Drupal 7.19 and Views 3.5 cache is not respecting contextual filter argument- it is displaying the same cache result no matter what argument given. How to get this working properly?
5
votes
2answers
4k views

Cache problem: update node

I am running a Drupal 7 website with "Cache pages for anonymous users" and "Cache blocks" enabled. Both "Minimum cache lifetime" and "Expiration of cached pages" are set to 1 day. When I update a ...
5
votes
1answer
2k views

TrustedResponseRedirect failing - how to prevent cache metadata?

I am getting the following when trying to redirect to an external site from my controller function defined in my routing file: return new TrustedRedirectResponse($my_ext_url); LogicException: The ...
4
votes
1answer
2k views

Caching Panel page variants

I don't believe I have never run into this before, but I have a Panels page with a few variants based on selection rules. Is there a way that you can serve up cached results for the whole page (not ...
3
votes
3answers
2k views

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class:...
3
votes
1answer
883 views

Showing local tasks in toolbar with hook_toolbar: caching problem

I'm creating a module using the toolbar api showing all administrative functions in a more compact toolbar. I'm having "cache" troubles showing the local tasks in the toolbar... How can I keep these ...
2
votes
1answer
2k views

Twig/Drupal caching and dynamic variables

I have a template with a list of recent articles and an article itself. I want to check in the list of recent articles if the article currently viewed is there and if yes add a class to the div. This ...
2
votes
2answers
1k views

Where is the best place for cache bins (Drupal 7)? [closed]

At Drupal 7, I have read about various solutions for storing the cache bins and avoiding having them at the standard drupal database. The methods are: - Memcache - Mongodb - APC - Filecache module? ...
2
votes
3answers
276 views

Caching strategy for a page that varies by IP

I've created a custom cache context that determines if a request comes from in my campus network or from outside my campus network: class NetworkContext extends RequestStackCacheContextBase ...
2
votes
4answers
2k views

How do I clear cache?

On my new site all works fine so far, except that when I try to clear cache (e.g. class cache or table cache or just flush all caches) from the UI. I sometimes get an error about exhausted memory (64M ...
2
votes
2answers
2k views

Generate image styles on upload or in some other memory-conscious fashion?

I have a D7 site that is hovering around 55mb on devel_shutdown(); for most uncached pages and has a lot of migrated content that has images linked to various styles around the site, many of which are ...
1
vote
1answer
3k views

Blank browser after clearing the cache

I migrated a site from windows xampp to ubuntu. It was working fine. But once I cleared the cache, the browser is showing blank screen.I tried going to different urls . I also tried clean urls but ...
1
vote
1answer
559 views

Cache max-age and varnish ESI

I need to display a custom block on my homepage. This custom block retrieves some data that are not managed by Drupal. Since no event will happen in Drupal to say that those data have changed, the max-...
1
vote
2answers
96 views

Turn off Twig cache in general

Drupal does cache Twig templates. Normally, it is a good thing, as long as you don't have a multilingual site. In my case every t()is not working as the template is cached in the wrong in English, ...
1
vote
2answers
4k views

Custom Block Class with custom Template, cache issue

I need add a custom block in my website, this block must show some users values (from customs fields). I can show all user variables I want but if a user value change for some reason, I must clear ...
1
vote
2answers
2k 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\...
1
vote
1answer
2k views

How to correctly use cookies? (Twig and cache context)

In my current project I need to alter node templates depending on previously visited landing page. My idea is that, when a visitor visits one of these landing pages, a cookie will be set, and ...
1
vote
1answer
1k views

7: How to cache $form[] elements in complex AJAX forms

How is it best to efficently rebuild your form on multiple AJAX requests? That is how can I cleanly cache individual elements so I don't need to rebuild them? Using static variables is not an option ...
1
vote
2answers
1k views

Messed Up Drupal Site, truncated all cache, menu_router, registry_file and now I can't access site

After disabling comment module, I could not access some modules, so I researched how to get that fixed and end up following this. I cleared all the cache_table, menu_router and registry_file. This ...
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 ...