I am using rails fragment caching and inside the fragment there is an image file. If i do a deploy (clearing the assets) with an updated image, the image digest fingerprint will change. So until the fragment expires it will be pointing to the old image and be broken. How can I expire the fragment to get the updated image (by the way I can't run rails cache clear
)?
Asked
Active
Viewed 332 times
0

Joel Brewer
- 1,622
- 19
- 30

peter
- 45
- 5
1 Answers
0
According to the Rails Cache Guide, You can expire a fragment
expire_fragment(controller: 'products', action: 'recent', action_suffix: 'all_products')
You can even name your cache segment, ie
<% cache('some_image') do %>
*Your code here*
<% end %>
And then expire it by that name
expire_fragment('some_image')

JTG
- 8,587
- 6
- 31
- 38
-
the issue with that solution is that i have to know all the cache fragments with images in them and thats not doable for a large website. – peter Nov 18 '14 at 20:49
-
You didn't really give any context to your coding situation, so its very difficult to provide an exact solution. Now that you know you can expire a fragment, I would suggest reading the Rails Cache Guide, and looking at some of the other options (such as a helper function). And the next time you ask a question, everyone might benefit if you provide code, context, what you've tried, and what you want. This give us a better idea on how to help you, then we can help more than posting a general solution with a link to a resource. Good Luck – JTG Nov 18 '14 at 21:25