You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -271,7 +271,10 @@ The options are the same options of ```ActiveSupport::Cache::Store```, plus
271
271
a ```key``` option that will be the prefix of the object cache
272
272
on a pattern ```"#{key}/#{object.id}-#{object.updated_at}"```.
273
273
274
+
The cache support is optimized to use the cached object in multiple request. An object cached on an ```show``` request will be reused at the ```index```. If there is a relationship with another cached serializer it will also be created and reused automatically.
275
+
274
276
**[NOTE] Every object is individually cached.**
277
+
275
278
**[NOTE] The cache is automatically expired after update an object but it's not deleted.**
276
279
277
280
```ruby
@@ -295,6 +298,27 @@ On this example every ```Post``` object will be cached with
295
298
the key ```"post/#{post.id}-#{post.updated_at}"```. You can use this key to expire it as you want,
296
299
but in this case it will be automatically expired after 3 hours.
297
300
301
+
### Fragmenting Caching
302
+
303
+
If there is some API endpoint that shouldn't be fully cached, you can still optmise it, using Fragment Cache on the attributes and relationships that you want to cache.
304
+
305
+
You can define the attribute by using ```only``` or ```except``` option on cache method.
306
+
307
+
**[NOTE] Cache serializers will be used at their relationships**
0 commit comments