Skip to content

Commit cda8c0f

Browse files
committed
add documentation about no cache middleware
1 parent 409b939 commit cda8c0f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

middlewares/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ Fano Framework provides several built-in middlewares.
306306
- `TValidationMiddleware`, middleware class which validate request. Read [Form Validation](/security/form-validation) for more information.
307307
- `TJsonContentTypeMiddleware`, middleware class which handle request with `application/json` in its header. For more information, read [Handling request with JSON body](/working-with-request#handling-request-with-json-body).
308308
- `TCacheControlMiddleware`, middleware class which adds `Cache-Control` response header. For more information, read [Http cache header](/working-with-response/http-cache-header).
309+
- `TNoCacheMiddleware`, middleware class which adds `Cache-Control` response header to prevent browser from caching response.
309310
- `TStaticFilesMiddleware`, middleware class which serves static files. For more information, read [Serving static files](/working-with-response/serve-static-files).
310311

311312
### Group several middlewares as one

working-with-response/http-cache-header/index.md

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ container.add(
9999
);
100100
```
101101

102+
## Prevent browser from caching response
103+
To prevent browser from caching response, you can use something like following example
104+
```
105+
container.add(
106+
'no-cache',
107+
TCacheControlMiddlewareFactory.create()
108+
.noStore()
109+
.mustRevalidate()
110+
);
111+
```
112+
or you can use `TNoCacheMiddleware` which specifically provided for this purpose
113+
```
114+
container.add('no-cache', TNoCacheMiddlewareFactory.create());
115+
```
116+
102117
## Explore more
103118

104119
- [Working with Request](/working-with-request)

0 commit comments

Comments
 (0)