->tags()
Attach cache tags to one response, so StaticCache::purgeTags() can purge it later.
php
return Inertia::render('Post/Show', ['post' => $post])
->tags(['posts', "post:{$post->id}", "author:{$post->author_id}"]);Reference
php
Inertia\Response::tags(array|string $tags): Inertia\ResponseTags from the route (->isr(tags: [...])) and from the response are merged. Calling it several times adds tags.
Good to know
- Pick tags from the data the page shows: a page listing posts gets
posts; a page showing post 42 getspost:42. HasStaticTagspurges[table, singular:id]by default (posts,post:42). Use the same names here.- Only applies to
israndstaticroutes. - CDNs without cache tags (Bunny, CloudFront, nginx) need the tag registry to purge by tag.
- The tag header is capped by the CDN's size limit (16 KB on Cloudflare and Fastly); tags beyond it are dropped.