You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can manually flush the prefetch cache by calling `router.flushAll` to remove all cached data, or `router.flush` to remove cache for a specific page.
For more granular control, you can flush cached data by their tags using `router.flushByCacheTags`. This removes any cached response that contains _any_ of the specified tags.
369
+
370
+
```js
371
+
// Flush all responses tagged with 'users'
372
+
router.flushByCacheTags('users')
373
+
374
+
// Flush all responses tagged with 'dashboard' OR 'stats'
375
+
router.flushByCacheTags(['dashboard', 'stats'])
376
+
```
377
+
378
+
### Invalidate on requests
379
+
380
+
@available_since core=2.1.2
381
+
382
+
To automatically invalidate caches when making requests, pass an `invalidateCacheTags` prop to the Form component. The specified tags will be flushed when the form submission succeeds.
383
+
384
+
:::tabs key:frameworks
385
+
386
+
== Vue
387
+
388
+
```vue
389
+
<script setup>
390
+
import { Form } from '@inertiajs/vue3'
391
+
</script>
392
+
393
+
<template>
394
+
<Form
395
+
action="/users"
396
+
method="post"
397
+
:invalidate-cache-tags="['users', 'dashboard']"
398
+
>
399
+
<input type="text" name="name" />
400
+
<input type="email" name="email" />
401
+
<button type="submit">Create User</button>
402
+
</Form>
403
+
</template>
404
+
```
405
+
406
+
== React
407
+
408
+
```jsx
409
+
import { Form } from'@inertiajs/react'
410
+
411
+
exportdefault () => (
412
+
<Form
413
+
action="/users"
414
+
method="post"
415
+
invalidateCacheTags={['users', 'dashboard']}
416
+
>
417
+
<input type="text" name="name"/>
418
+
<input type="email" name="email"/>
419
+
<button type="submit">Create User</button>
420
+
</Form>
421
+
)
422
+
```
423
+
424
+
== Svelte 4 | Svelte 5
425
+
426
+
```svelte
427
+
<script>
428
+
import { Form } from '@inertiajs/svelte'
429
+
</script>
430
+
431
+
<Form
432
+
action="/users"
433
+
method="post"
434
+
invalidateCacheTags={['users', 'dashboard']}
435
+
>
436
+
<input type="text" name="name" />
437
+
<input type="email" name="email" />
438
+
<button type="submit">Create User</button>
439
+
</Form>
440
+
```
441
+
442
+
:::
443
+
444
+
With the `useForm` helper, you can include `invalidateCacheTags` in the visit options.
445
+
446
+
:::tabs key:frameworks
447
+
448
+
== Vue
449
+
450
+
```vue
451
+
import { useForm } from '@inertiajs/vue3' const form = useForm({ name: '',
0 commit comments