async_render 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +27 -2
- data/lib/async_render/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4198331a3b4cea32f2e5efb02ca0f616bca9d77796ba0e39df3bf467258cc878
|
4
|
+
data.tar.gz: 2e99dfe1fc5cf022f96b5df0175e1ed1c7dda1412aad4254f53cdb05b26774a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: befb63ff7447523674815182bbf5728ce0f0bf0995aeb0072f1b5d51912e05738f69a57588d47682c1b7ab2a6a6ed1ab1a5bed35cba2b1755b125c76f42b52f3
|
7
|
+
data.tar.gz: a54e8796393bd64f4262c555fc5245efd71ea44fe38c939bd486bf00df2b1e29ebd140622879edd2e3466a2220c7878e4cd2068109ac48ef4a5cbdbd8cb119e0
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ On my pet project and my benchmark, I've seen 5-15% improvement in response time
|
|
11
11
|
- you have heavy partials
|
12
12
|
- you have partials, with calculations inside, that can be done in background
|
13
13
|
- your partials has none or a few dependencies on locals
|
14
|
+
- you have 2+ partials with rendering time more than 100ms
|
14
15
|
- you have HTML request format (see `Limitations` section)
|
15
16
|
- you are curious about performance :)
|
16
17
|
|
@@ -19,16 +20,27 @@ On my pet project and my benchmark, I've seen 5-15% improvement in response time
|
|
19
20
|

|
20
21
|
|
21
22
|
### 🔄 Async Rendering
|
23
|
+
|
22
24
|
Render multiple view partials asynchronously in background threads, reducing overall page load time by executing independent renders concurrently.
|
23
25
|
|
26
|
+
Use cases:
|
27
|
+
- heavy partials, maybe with calculations inside
|
28
|
+
- 2+ partials with rendering time more than 100ms
|
29
|
+
|
24
30
|
### 🔥 Warmup Rendering
|
31
|
+
|
25
32
|
Pre-render partials in your controller actions before the main view is processed. This allows expensive computations to start early and be ready when needed. This must be used in combination with async rendering.
|
26
33
|
|
34
|
+
Use cases:
|
35
|
+
- you are sure that some partials will be rendered
|
36
|
+
|
27
37
|
### 💾 Memoized Rendering
|
38
|
+
|
28
39
|
Cache rendered partials in memory across requests within the same Ruby process, eliminating redundant rendering of static or rarely-changing content. Warning: do not use it for large amount of content, it will eat up your memory.
|
29
40
|
|
30
|
-
|
31
|
-
|
41
|
+
Use cases:
|
42
|
+
- you have static or rarely-changing content (like google analytics, modal, etc)
|
43
|
+
- it's okay to cache it in memory, and it will be reset after next deployment
|
32
44
|
|
33
45
|
## 📦 Installation
|
34
46
|
|
@@ -160,6 +172,7 @@ For content that rarely changes, use memoized rendering to cache results in memo
|
|
160
172
|
- if you use "Current" attributes, you need to pass them as locals, or pass as state to render (see `dump_state_proc` and `restore_state_proc` in the initializer)
|
161
173
|
- warmup rendering under the hood uses simply before_action, so you need to prepare data in the controller action, not in the view.
|
162
174
|
- for now only HTML request format is supported, but I'm working on it.
|
175
|
+
- it will mess up your logs, because some rendering may happen after logs like "Completed 200 OK in 1761ms".
|
163
176
|
|
164
177
|
### ✅ Do
|
165
178
|
|
@@ -175,6 +188,18 @@ For content that rarely changes, use memoized rendering to cache results in memo
|
|
175
188
|
- Rely on request-specific data without proper state management
|
176
189
|
- Use excessive async rendering that could exhaust database connections
|
177
190
|
|
191
|
+
## Testing in Production
|
192
|
+
|
193
|
+
For example you can disable async rendering:
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
class ApplicationController < ActionController::Base
|
197
|
+
before_action do
|
198
|
+
AsyncRender.enabled = params[:skip_async].blank?
|
199
|
+
end
|
200
|
+
end
|
201
|
+
```
|
202
|
+
|
178
203
|
## Performance Considerations
|
179
204
|
|
180
205
|
- The gem automatically limits parallelism based on available database connections
|
data/lib/async_render/version.rb
CHANGED