Skip to content

Commit

Permalink
docs: update README.md about disable index.html cache
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatAuk committed Oct 27, 2023
1 parent c1e2380 commit 40fe6c8
Show file tree
Hide file tree
Showing 10 changed files with 340 additions and 85 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### Important: Disable `index.html` caching!

If `index.html` is cached, the update notification may still appear after refreshing, so it is necessary to disable the caching of `index.html`. This is also a best practice for deploy SPA applications.

To disable caching through `nginx`:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

Directly disable caching through `html meta` tags:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**basic usage**
Expand Down
51 changes: 34 additions & 17 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### 关键:禁用 `index.html` 缓存!!!

如果 `index.html` 存在缓存,可能刷新后,更新提示还会存在,所以需要禁用 `index.html` 的缓存。这也是 `SPA` 应用部署的一个最佳实践吧。

通过 `nginx` ,禁用缓存:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

直接通过 `html meta` 标签禁用缓存:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**基础使用**
Expand Down Expand Up @@ -192,23 +226,6 @@ module.exports = defineConfig({
})
```

### 建议: 如果是 SPA 应用,禁用 `index.html` 的缓存

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```



## webUpdateNotice Options

```ts
Expand Down
34 changes: 34 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### Important: Disable `index.html` caching!

If `index.html` is cached, the update notification may still appear after refreshing, so it is necessary to disable the caching of `index.html`. This is also a best practice for deploy SPA applications.

To disable caching through `nginx`:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

Directly disable caching through `html meta` tags:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**basic usage**
Expand Down
51 changes: 34 additions & 17 deletions packages/core/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### 关键:禁用 `index.html` 缓存!!!

如果 `index.html` 存在缓存,可能刷新后,更新提示还会存在,所以需要禁用 `index.html` 的缓存。这也是 `SPA` 应用部署的一个最佳实践吧。

通过 `nginx` ,禁用缓存:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

直接通过 `html meta` 标签禁用缓存:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**基础使用**
Expand Down Expand Up @@ -192,23 +226,6 @@ module.exports = defineConfig({
})
```

### 建议: 如果是 SPA 应用,禁用 `index.html` 的缓存

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```



## webUpdateNotice Options

```ts
Expand Down
34 changes: 34 additions & 0 deletions packages/umi-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### Important: Disable `index.html` caching!

If `index.html` is cached, the update notification may still appear after refreshing, so it is necessary to disable the caching of `index.html`. This is also a best practice for deploy SPA applications.

To disable caching through `nginx`:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

Directly disable caching through `html meta` tags:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**basic usage**
Expand Down
51 changes: 34 additions & 17 deletions packages/umi-plugin/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### 关键:禁用 `index.html` 缓存!!!

如果 `index.html` 存在缓存,可能刷新后,更新提示还会存在,所以需要禁用 `index.html` 的缓存。这也是 `SPA` 应用部署的一个最佳实践吧。

通过 `nginx` ,禁用缓存:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

直接通过 `html meta` 标签禁用缓存:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**基础使用**
Expand Down Expand Up @@ -192,23 +226,6 @@ module.exports = defineConfig({
})
```

### 建议: 如果是 SPA 应用,禁用 `index.html` 的缓存

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```



## webUpdateNotice Options

```ts
Expand Down
34 changes: 34 additions & 0 deletions packages/vite-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,40 @@ pnpm add @plugin-web-update-notification/webpack -D

[vite](#vite) | [umi](#umijs) | [webpack](#webpack)

### Important: Disable `index.html` caching!

If `index.html` is cached, the update notification may still appear after refreshing, so it is necessary to disable the caching of `index.html`. This is also a best practice for deploy SPA applications.

To disable caching through `nginx`:

```nginx
# nginx.conf
location / {
index index.html index.htm;
if ( $uri = '/index.html' ) { # disabled index.html cache
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
try_files $uri $uri/ /index.html;
}
```

Directly disable caching through `html meta` tags:

```html
<!DOCTYPE html>
<html lang="en">
<head>

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

</head>
</html>
```

### Vite

**basic usage**
Expand Down
Loading

0 comments on commit 40fe6c8

Please sign in to comment.