Skip to content

Commit ca3a099

Browse files
docs: improve writing quality across all documentation pages (#1210)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: arthurfiorette <47537704+arthurfiorette@users.noreply.github.com>
1 parent 8d3840a commit ca3a099

File tree

11 files changed

+45
-47
lines changed

11 files changed

+45
-47
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
- 🌐 No network waste!
4343
- 🔑 TypeScript!
4444

45-
Axios Cache Interceptor is, as it name says, a interceptor for axios to handle caching. It
46-
was created to help developers call axios multiple times without having to worry about
47-
overloading the network or coding himself a simple and buggy cache system.
45+
Axios Cache Interceptor is, as its name says, an interceptor for axios to handle caching.
46+
It was created to help developers call axios multiple times without having to worry about
47+
overloading the network or implementing a simple and error-prone cache system.
4848

4949
<br />
5050

@@ -74,7 +74,7 @@ res2.cached; // true
7474

7575
## License
7676

77-
Licensed under the **MIT**. See [`LICENSE`](LICENSE) for more informations.
77+
Licensed under the **MIT**. See [`LICENSE`](LICENSE) for more information.
7878

7979
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Farthurfiorette%2Faxios-cache-interceptor.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Farthurfiorette%2Faxios-cache-interceptor?ref=badge_small)
8080

docs/src/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const cache = setupCache(Axios.create(), {
6262
- Default: `buildMemoryStorage()`
6363

6464
A storage interface is the entity responsible for saving, retrieving and serializing data
65-
received from network and requested when a axios call is made.
65+
received from the network when an axios call is made.
6666

6767
See the [Storages](./guide/storages.md) page for more information.
6868

@@ -260,7 +260,7 @@ This option only works when targeting a [Development](./guide/debugging.md) buil
260260

261261
The debug option will print debug information in the console. It is good if you need to
262262
trace any undesired behavior or issue. You can enable it by setting `debug` to a function
263-
that receives an string and returns nothing.
263+
that receives a string and returns nothing.
264264

265265
Read the [Debugging](./guide/debugging.md) page for the complete guide.
266266

docs/src/config/request-specifics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ the interpreter can't determine their TTL value to override this one.
132132

133133
The time until the cached value is expired in milliseconds.
134134

135-
If a function is used, it will receive the complete response and waits to return a TTL
135+
If a function is used, it will receive the complete response and should return a TTL
136136
value
137137

138138
The `ttl` is only applied when the response is **first cached**; changing it on follow-up
@@ -145,8 +145,8 @@ requests has no effect. See [#1024](https://github.com/arthurfiorette/axios-cach
145145
- Type: `boolean`
146146
- Default: `true`
147147

148-
If activated, when the response is received, the `ttl` property will be inferred from the
149-
requests headers. As described in the MDN docs and HTML specification.
148+
If enabled, when the response is received, the `ttl` property will be inferred from the
149+
response headers, as described in the MDN docs and the HTTP specification.
150150

151151
See the actual implementation of the
152152
[`interpretHeader`](https://github.com/arthurfiorette/axios-cache-interceptor/blob/main/src/header/interpreter.ts)
@@ -320,7 +320,7 @@ axios.post<{ auth: { user: User } }>(
320320
{
321321
cache: {
322322
update: {
323-
// Evicts the profile info cache, because now he is authenticated and the response needs to be re-fetched
323+
// Evicts the profile info cache, because the user is now authenticated and the response needs to be re-fetched
324324
[profileInfoId]: 'delete',
325325

326326
// An example that update the "user info response cache" when doing a login.

docs/src/config/response-object.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Response object
22

3-
Axios cache interceptor returns a slightly different response than the original axios response.
3+
Axios Cache Interceptor returns a slightly different response than the standard axios response.
44
It contains information about the cache and other needed properties.
55

66
## id
@@ -38,4 +38,4 @@ This does not indicate if the request was capable of being cached or not, as opt
3838

3939
- Type: `boolean`
4040

41-
A simple boolean indicating if the request returned data is from valid or stale cache.
41+
A simple boolean indicating whether the returned data is from a valid or stale cache.

docs/src/guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Axios Cache Interceptor is an interceptor for axios, as its name says, to handle caching.
44
It was created to help developers call axios multiple times without having to worry about
5-
overloading the network or coding themselves a simple and buggy cache system.
5+
overloading the network or implementing a simple and error-prone cache system.
66

77
Each request goes through an interceptor applied to your axios instance. There, we handle
88
each request and decide if we should send it to the network or return a cached response.
@@ -21,7 +21,7 @@ cached (sometimes you don't want cache at all, and that's ok), if there's alread
2121
sent to the network that we can wait for, and many other checks.
2222

2323
After the adapter gets the response, we check if it belongs to a _cacheable_ request,
24-
saves it into the storage, resolves other requests awaiting for the same resource and
24+
saves it to the storage, resolves other requests waiting for the same resource and
2525
finally returns the response to the original caller.
2626

2727
## Features
@@ -47,7 +47,7 @@ more than 4x the size of this library with fewer features and less performance.
4747
### Fetch and some state management library?
4848

4949
As this library was built to be used with axios and to handle storage itself, I can assure
50-
that it is more performant than any glued code you may find and/or write yourself. About
50+
that it is more performant than any hand-rolled code you may find or write yourself. About
5151
state management libraries and other similar things,
5252
[this blog post](https://arthur.place/implications-of-cache-or-state) explains why cache
5353
is the more correct, architectural way, instead of state.

docs/src/guide/debugging.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Debugging
22

3-
I'm certainly sure that along the way you will find some cache behavior that is not the
4-
expected to the current situation. To help with that, the library has a separate robust
5-
build with support to debug logs enabled.
3+
At some point, you may encounter cache behavior that does not match expectations. To help
4+
diagnose such issues, the library provides a separate build with debug logging enabled.
65

76
You can use it by changing the `setupCache` import:
87

@@ -61,8 +60,8 @@ const axios = setupCache(Axios, {
6160

6261
:::
6362

64-
And much more, depending on your context, situation and configuration. **Any misbehavior
65-
that you find will have a log to explain it.**
63+
And much more, depending on your context, situation, and configuration. **Any misbehavior
64+
you encounter will have a log to explain it.**
6665

6766
::: details Sample of logs sent to console.
6867

docs/src/guide/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interceptor ordering, see [Other Interceptors](./interceptors.md).
105105

106106
Just the above is sufficient for most use cases. However, you can also customize each
107107
cache behavior by passing a configuration object to the `setupCache` function. And you can
108-
also customize some behaviors each request by using the `cache` option in the request
108+
also customize some behaviors per request by using the `cache` option in the request
109109
config.
110110

111111
## Support Table

docs/src/guide/interceptors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ axios.interceptors.request.use(
7171

7272
## Extending types
7373

74-
When using axios-cache-interceptor, you'll note that it has a different type than the defaults `AxiosInstance`, `AxiosRequestConfig` and `AxiosResponse`. That's because we chose to override axios's interfaces instead of extending, to avoid breaking changes with other libraries.
74+
When using axios-cache-interceptor, you'll notice that it has a different type than the defaults `AxiosInstance`, `AxiosRequestConfig` and `AxiosResponse`. That's because we chose to override axios's interfaces instead of extending, to avoid breaking changes with other libraries.
7575

7676
However, this also means that when integrating with other packages or creating your own
7777
custom interceptor, you need to override/extend our own types, `CacheInstance`,
@@ -92,7 +92,7 @@ declare module 'axios-cache-interceptor' {
9292
Sometimes you may want to cache a response that is not `JSON`, or that is a `Stream`.
9393
Either created by another interceptor or even by the axios adapter itself.
9494

95-
To do so, you can use the axios's native `transformResponse` option, which is a function
95+
To do so, you can use axios's native `transformResponse` option, which is a function
9696
that receives the response and returns a string or a buffer.
9797

9898
**Axios Cache Interceptor** can only handle serializable data types, so you need to

docs/src/guide/invalidating-cache.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Invalidating Cache
22

33
When using cache-first approaches to improve performance, data inconsistency becomes your
4-
major problem. That occurs because **you** can mutate data in the server and **others**
5-
also can too. It becomes impossible to really know what the current state of the data is
4+
major problem. That occurs because **you** can mutate data on the server and so can
5+
**others**. It becomes impossible to really know what the current state of the data is
66
in real time without communicating with the server.
77

88
::: warning
@@ -25,9 +25,9 @@ Take a look at this simple example:
2525

2626
## Revalidation after mutation
2727

28-
In most cases, you are the one responsible for that inconsistency, like in the above
29-
example when the client itself initiated the mutation request. When that happens, you are
30-
capable of invalidating the cache for all places you have changed too.
28+
In most cases, you are responsible for that inconsistency — as in the example above,
29+
where the client itself initiated the mutation request. When that happens, you can
30+
invalidate the cache for all the entries you have changed.
3131

3232
**The `cache.update` option is available for every request that you make, and it will be
3333
the go-to tool for invalidation.**
@@ -90,8 +90,8 @@ function createPost(data) {
9090
```
9191

9292
This will update the `list-posts` cache at the client side, making it equal to the server.
93-
When operations like this are possible to be made, they are the preferred. That's because
94-
we do not contact the server again and update ourselves the cache.
93+
When such operations are possible, they are the preferred approach. That's because
94+
we do not contact the server again and can update the cache ourselves.
9595

9696
::: tip
9797

@@ -148,14 +148,14 @@ function createPost(data) {
148148
}
149149
```
150150

151-
Still using the first example, while we are at the step **3**, automatically, the axios
152-
cache-interceptor instance will request the server again and do required changes in the
153-
cache before the promise resolves and your page gets rendered.
151+
Continuing with the first example, at step **3**, the axios-cache-interceptor instance
152+
will automatically request the server again and apply the necessary cache changes before
153+
the promise resolves and your page gets rendered.
154154

155155
## Through external sources
156156

157-
If you have any other type of external communication, like when listening to a websocket
158-
for changes, you may want to update your axios cache without be in a request context.
157+
If you have any other type of external communication, such as a WebSocket listener for
158+
changes, you may want to update your axios cache outside of a request context.
159159

160160
For that, you can operate the storage manually. It is simple as that:
161161

@@ -206,14 +206,13 @@ function createPost(data) {
206206
}
207207
```
208208

209-
## Summing up
209+
## Summary
210210

211-
When applying any kind of cache to any kind of application, you chose to trade data
212-
consistency for performance. And, most of the time that is OK.
211+
When applying any kind of cache to any application, you choose to trade data
212+
consistency for performance. And, most of the time, that is OK.
213213

214214
_The best cache strategy is a combination of all of them. TTL, custom revalidation, stale
215215
while revalidate and all the others together are the best solution._
216216

217-
The only real tip here is to you put on a scale the amount of inconsistency you are
218-
willing to give up for the performance you are willing to gain. **Sometimes, not caching
219-
is the best solution.**
217+
The only real advice is to weigh the amount of inconsistency you are willing to accept
218+
against the performance you want to gain. **Sometimes, not caching is the best solution.**

docs/src/guide/request-id.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const userForPageY = await axios.get('/users', { id: 'users-page-y' });
3939

4040
::: warning
4141

42-
If you send two different requests forcefully with the same ID. This library will ignore
42+
If you forcefully send two different requests with the same ID, this library will ignore
4343
any possible differences between them and share the same cache for both.
4444

4545
:::
@@ -67,7 +67,7 @@ possibility
6767

6868
:::
6969

70-
Here's an example of a generator that only uses the `url` and `method` and `custom`
70+
Here's an example of a generator that only uses the `url`, `method`, and `custom`
7171
properties:
7272

7373
```ts

0 commit comments

Comments
 (0)