New answers tagged

0

Some forms generated by Drupal 8(.7.8)'s FAPI crash when cached server side using Drupal 8's cache, and loaded by an anonymous user. If you clear the server side cache($ drush cr), the anonymous user can then load the form successfully; on refresh it crashes once cached server side and reloaded by the user. In this case, BrianV's answer ($form['#cache'] = [...


0

My understanding is that you're trying to set a cache max-age of 0 (don't cache) for a paragraph. I think your issue here is that the max-age doesn't bubble up to the page level and the page cache still caches your paragraph. This makes it so your paragraph is not processed again. My understanding is that cache max-age data doesn't bubble up to the page ...


0

You've got a logic error in your PHP. You're doing the following and setting some variables: $variables['elements']['#cache']['max-age'] = '0'; $variables['elements']['#cache']['contexts'][] = 'url.path'; $variables['elements']['#cache']['contexts'][] = 'url.query_args:r'; But then in the next line you're redeclaring $variables['elements']['#cache'] as a ...


1

To sum up the comments: As a general rule, if you render the current user, then always add the correct cache metadata to the render element: public function build() { return [ '#markup' => '<span>Current User ID: ' . \Drupal::currentUser()->id() . '</span>', '#cache' => [ 'contexts' => ['user'], 'tags'...


0

The answer by Ahmed tells you to use the "Import" tab provided by the Administration GUI to download the file and (re-)import after editing it. As an alternative, you may use the CLI and the following sequence of Drush commands: $ drush l10n-update-refresh $ drush l10n-update-status $ drush l10n-update This is quicker if you are comfortable with the GUI ...


0

The easier method to achieve this is by declaring and defining the getCacheContexts() method public function build() { $search_form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\SearchForm'); return [ 'search_form' => $search_form ]; } /** * {@inheritdoc} */ public function getCacheMaxAge() { // If you ...


0

You can try add to file settings.php $databases['default']['default']['init_commands'] = array( 'isolation' => "SET SESSION tx_isolation='READ-COMMITTED'" ); https://support.acquia.com/hc/en-us/articles/360005253954-Fixing-database-deadlocks


0

i had this bug a while ago , and i found this fixing dead locks in drupal ALTER TABLE semaphore ENGINE = MEMORY; ALTER TABLE semaphore DROP PRIMARY KEY; ALTER TABLE semaphore ADD PRIMARY KEY (name, value) USING BTREE; ALTER TABLE semaphore ADD UNIQUE name (name) USING BTREE; ALTER TABLE semaphore DROP INDEX value; ALTER TABLE semaphore ADD INDEX value (...


0

You can enable alternative cache implementation (with cache bootstrap) memcache or redis. Read more about deadlocks: https://support.acquia.com/hc/en-us/articles/360005253954-Fixing-database-deadlocks


0

For anyone stumbling across this, the following worked for me: '#cache' => [ 'contexts' => [ 'url.path', ], ], The key is to look at the available cache contexts, in this case, setting by URL. So example including above would be: $items[$key]['tray'] = [ '#heading' => t('Secondary tasks'), 'toolbar_secondary_tasks' => [ '#...


0

Best I can find on Google is that this header (and its companion header 'X-Speed-Cache') are added by a web server level module called "Speed Booster" touted as part of the Drupal Platform 'BOA': https://groups.drupal.org/node/173219 and https://omega8.cc/features . The purpose of the header seems to be nothing more than a debug header to check which key ...


0

I did it implementing a middleware: mymodule/mymodule.services.yml: mymodule.http_middleware: class: Drupal\mymodule\StackMiddleware\BeforePageCache arguments: - '@cache_tags.invalidator' tags: - { name: http_middleware, priority: 280, responder: true } mymodule/src/StackMiddleware/BeforePageCache.php ... /** * {@inheritdoc} */ public ...


0

If you want to completely disable caching for the block, use this function in your block class: public function getCacheMaxAge() { return 0; } I've never found in the documentation why '#cache' => [ 'max-age' => 0, ], doesn't work with blocks but, like you discovered, it doesn't seem to.


5

Instead of \Drupal::service('router.builder')->rebuild() you can invalidate route matches: Cache::invalidateTags(['route_match']); You don't need to rebuild the router table, because the static routes don't change. What you need to clear are route matches, which are calculated on the processed path and then stored for the unprocessed path. And this is ...


1

This is caused by symfony. private is added via vendor/symfony/http-foundation/ResponseHeaderBag.php and as far as I understand it's not possible to not have it when system.performance:cache.page.max_age is set to 0: protected function computeCacheControlValue() { // ... if (!isset($this->cacheControl['s-maxage'])) { return $header.', private'; ...


Top 50 recent answers are included