원클릭으로
drupal-caching
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
HTMX in Drupal 11.3+ core — the Htmx PHP fluent builder, dynamic forms with swapOob, partial routes with _htmx_route, response headers, and Drupal.behaviors integration. Use when building interactive UI without full-page reloads using Drupal's native HTMX support.
DDEV local development expertise. Use when working with DDEV projects, containers, configuration, or troubleshooting DDEV environments.
Custom Docker Compose local development patterns. Use when working with Docker-based local environments, container configuration, or troubleshooting Docker setups.
Drupal access control — permissions.yml, access callbacks, AccessResult, custom access checkers, and entity access.
Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.
Drupal configuration management with Drush — import/export config, preview config changes before applying (e.g., seeing what would change without importing), config splits, and environment syncing.
| name | drupal-caching |
| description | Drupal Cache API — cache tags, contexts, max-age, cache bins, invalidation, and adding cache metadata to render arrays. |
Always add cache metadata. Missing cache metadata causes stale content.
$build['content'] = [
'#markup' => $output,
'#cache' => [
'tags' => ['node:' . $node->id(), 'node_list'],
'contexts' => ['user.permissions', 'url.query_args'],
'max-age' => Cache::PERMANENT,
],
];
| Tag | Invalidated when |
|---|---|
node:{nid} | Node {nid} is saved/deleted |
node_list | Any node is created or deleted |
user:{uid} | User {uid} is saved |
taxonomy_term:{tid} | Term {tid} is saved |
config:{name} | Config object {name} is saved |
| Context | Varies by |
|---|---|
user.permissions | User's permissions (prefer over user) |
user.roles | User's roles |
url.path | URL path |
url.query_args | Query parameters |
languages | Current language |
$cached = $this->cacheBackend->get('my_module:my_key');
if ($cached !== FALSE) {
return $cached->data;
}
$this->cacheBackend->set('my_module:my_key', $data, Cache::PERMANENT, ['node_list']);
$this->cacheBackend->set('my_module:my_key', $data, \Drupal::time()->getRequestTime() + 3600, ['node_list']);
$this->cacheBackend->delete('my_module:my_key');
Cache::invalidateTags(['node:123', 'node_list']);
use Drupal\Core\Cache\CacheBackendInterface;
public function __construct(
private readonly CacheBackendInterface $cacheBackend,
) {}
# services.yml
my_module.my_service:
arguments: ['@cache.default']
$build['#cache']['tags'] = Cache::mergeTags(
$build['#cache']['tags'] ?? [],
$node->getCacheTags()
);