1
- import { A , Code , H1 , H2 , P , TabbedCode } from '@/Components'
1
+ import { A , Code , CodeBlock , H1 , H2 , P , TabbedCode } from '@/Components'
2
2
import dedent from 'dedent-js'
3
3
4
4
export const meta = {
@@ -7,6 +7,7 @@ export const meta = {
7
7
{ url : '#introduction' , name : 'Introduction' } ,
8
8
{ url : '#configuration' , name : 'Configuration' } ,
9
9
{ url : '#cache-busting' , name : 'Cache busting' } ,
10
+ { url : '#manual-refreshing' , name : 'Manual refreshing' } ,
10
11
] ,
11
12
}
12
13
@@ -72,9 +73,40 @@ export default function () {
72
73
busting. For example, appending a version query parameter to the end of your asset URLs.
73
74
</ P >
74
75
< P >
75
- If you're using Laravel Mix, you can do this automatically by enabling{ ' ' }
76
- < A href = "https://laravel.com/docs/mix#versioning-and-cache-busting" > versioning</ A > in your{ ' ' }
77
- < Code > webpack.mix.js</ Code > file. When using Laravel's Vite integration, asset versioning is done automatically.
76
+ With Laravel's Vite integration, asset versioning is done automatically. If you're using Laravel Mix, you can do{ ' ' }
77
+ this automatically by enabling < A href = "https://laravel.com/docs/mix#versioning-and-cache-busting" > versioning</ A > in your{ ' ' }
78
+ < Code > webpack.mix.js</ Code > file.
79
+ </ P >
80
+ < H2 > Manual refreshing</ H2 >
81
+ < P >
82
+ If you want to take asset refreshing into your control, you can return a fixed value from the < Code > version</ Code > method in the{ ' ' }
83
+ < Code > HandleInertiaRequests</ Code > middleware. This disables Inertia's automatic asset versioning.
84
+ </ P >
85
+ < P >
86
+ For example, if you want to notify users when a new version of your frontend is available, you can still expose{ ' ' }
87
+ the actual asset version to the frontend by including it as < A href = "/shared-data" > shared data</ A > .
88
+ </ P >
89
+ < CodeBlock
90
+ language = "php"
91
+ children = { dedent `
92
+ class HandleInertiaRequests extends Middleware
93
+ {
94
+ public function version(Request $request)
95
+ {
96
+ return null;
97
+ }
98
+
99
+ public function share(Request $request)
100
+ {
101
+ return array_merge(parent::share($request), [
102
+ 'version' => parent::version($request),
103
+ ]);
104
+ }
105
+ }
106
+ ` }
107
+ />
108
+ < P >
109
+ On the frontend, you can watch the < Code > version</ Code > property and show a notification when a new version is detected.
78
110
</ P >
79
111
</ >
80
112
)
0 commit comments