Skip to content

Commit a0661ce

Browse files
authored
feat: update caching docs: (#101)
1 parent 02368dd commit a0661ce

File tree

1 file changed

+6
-28
lines changed

1 file changed

+6
-28
lines changed

docs/technical-overview/caching.md

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,26 @@ sidebar_position: 8
44

55
# Caching
66

7-
:::important
8-
9-
We’re currently making rapid changes to the product so our docs may be out of date. If you need help, please email [yo@forem.com](mailto:yo@forem.com).
10-
11-
:::
127

138
_This has been adapted from [The Three Caches of Forem // Take on Rules](https://takeonrules.com/2022/03/29/the-three-caches-of-forem/)_
149

1510

1611
In the Forem code base, we make extensive use of various caching strategies. And as with any cache, we always run the risk of not invalidating the right caches.
1712

18-
The three caching strategies are:
19-
20-
- Edge Caching
21-
- Rails Caching
22-
- Database Caching
13+
You can read more about our response caching strategies here:
14+
https://dev.to/devteam/caching-at-dev-11el
2315

24-
At a high level, we leverage caches to improve performance. Let’s delve into each strategy. But before we do, let’s introduce a few concepts.
16+
We also dive more into Rails Caching which touches on (Fragment Caching)and Database Caching below.
2517

26-
## Response Documents and Fragments
18+
At a high level, we leverage caches to improve performance. Let’s start of by introducing by detailing what a Response Document and Fragment is.
2719

2820
The <dfn>response document</dfn> is a single file sent from the server in response to a request.
2921

3022
Remember that what you see rendered in your browser is almost always from the combination of many _response documents_ sent from the server: <abbr title="Hypertext Markup Language">HTML</abbr> documents, Javascript files, <abbr title="Cascading Stylesheet">CSS</abbr> files, and <abbr title="XMLHttpRequest">XHR</abbr> that modify the <abbr title="Document Object Model">DOM</abbr>.
3123

3224
To build a single _response document_, the server often assembles multiple fragments to form that singular document. In Ruby on Rails this is done with like layouts, views, and partial views.
3325

34-
## Back to Listing the Caching Strategies
35-
36-
Let’s now work from the broader caching strategies to the more narrow ones.
37-
38-
### Edge Caching
39-
40-
Edge caching is about trying to put as many of the _response documents_ as close to the client as possible to reduce latency on content delivery.
41-
42-
At Forem, we enable the usage of either Fastly or Nginx. When we bust the edge cache, we are evicting specific _response documents_.
43-
44-
The next time someone requests that _response document_ the server will reassemble it (from the various constituent parts).
45-
46-
You can see [our Edge Busting strategy here](https://github.com/forem/forem/blob/main/app/services/edge_cache/bust.rb).
47-
48-
### Rails Caching
26+
## Rails Caching
4927

5028
We use the Rails cache to store all kinds of things, mostly fragments that we use to build the response document.
5129

@@ -63,7 +41,7 @@ When an admin makes a site wide change, that prompts to use a new key; so long a
6341

6442
You can learn more about [Caching with Rails](https://guides.rubyonrails.org/caching_with_rails.html) over at the Rails Guides.
6543

66-
### Database Caching
44+
## Database Caching
6745

6846
The last is database caching. We cache an article’s tag list, user, and organization information (if applicable). These are cached as fields on the articles table. The purpose of these cached attributes is performance. Where possible, we prefer to minimize joins for queries that we frequently perform (e.g. get me a list of articles being a very common query for a Forem).
6947

0 commit comments

Comments
 (0)