[openstreetmap/openstreetmap-website] Cache social link platform and name at save time (PR #6950)
Pablo Brasero
notifications at github.com
Fri Apr 3 07:25:05 UTC 2026
@pablobm commented on this pull request.
> @@ -2,13 +2,14 @@
<ul class="list-unstyled social_links mb-0">
<% social_links.each do |social_link| %>
+ <% parsed = Rails.cache.fetch("social_link/#{social_link.url}") { social_link.parsed } %>
Since we are at it, we can cache the generated HTML. It saves a bit more effort for the template engine and avoids having to work with variables (`parsed`) in the template:
```erb
<% Rails.cache.fetch("social_link/#{social_link.url}") do %>
<li>
(...)
</li>
<% end %>
```
Having said that, a problem in general with using `Rails.cache` is what to do when we introduce icons for new services, like we did at https://github.com/openstreetmap/openstreetmap-website/pull/6855. However I don't think this is vey common, and any solution is going to require having to clean the cache.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6950?email_source=notifications&email_token=AAK2OLJ5AKOYCQUSEASWUTD4T5RNDA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMBVGQ3DEMJXGQZ2M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOS6XA4S7OJSXM2LFO5PW433UNFTGSY3BORUW63TTL5RWY2LDNM#pullrequestreview-4054621743
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/6950/review/4054621743 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260403/df6850ca/attachment.htm>
More information about the rails-dev
mailing list