Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
To change the default cache experiration time please execute:
$desired_expiration_time = 500; // 500 seconds
\Drupal::configFactory()->getEditable('prefetch_cache.settings')->set('time_to_live', $desired_expiration_time)->save();
The module gives also the ability to define custom cache tags for the cache entries for each request, so that even custom forms might be cached and invalidated.
For this a CacheTagsGenerator implementing the CacheTagsGeneratorInterface should be created and should be defined as a service with the tag
- { name: prefetch_cache_cache_tags_generator }
so that it is automatically added to the chain of Cache Tags Generators.