forked from OpenNeo/impress
Start serving outfit images via Impress 2020
As part of our project to get off S3 and dramatically reduce costs, we're gonna start serving outfit images that Impress 2020 generates, fronted by Vercel's CDN cache! This should hopefully be just as fast in practice, without requiring an S3 storage cost. (Outfits whose thumbnails are pretty much unused will be evicted from the cache, or never stored in the first place—and regenerated back into the cache on-demand if needed.) One important note is that the image at the URL will no longer be guaranteed to auto-update to reflect the changes to the outfit, because we're including `updated_at` in the URL for caching. (It also isn't guaranteed to _not_ auto-update, though 😅) Our hope is that people aren't using it for that use case so much! If so, though, we have some ways we could build live URLs without putting too much pressure on image generation, e.g. redirects 🤔 This change does _not_ disable actual outfit generation, because I want to keep that running until we see these new URLs succeed for folks. Gonna wait a bit and see if we get bug reports on them! Then, if all goes well, we'll stop enqueueing outfit image jobs altogether, and maybe wind down some of the infrastructure accordingly.
This commit is contained in:
parent
3ae8a265b2
commit
b31a22d4a1
1 changed files with 19 additions and 4 deletions
|
@ -27,10 +27,25 @@ class Outfit < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def image_versions
|
||||
{}.tap do |versions|
|
||||
versions[:large] = image.url
|
||||
image.versions.each { |name, version| versions[name] = version.url }
|
||||
end
|
||||
# Now, instead of using the saved outfit to S3, we're trying out the
|
||||
# DTI 2020 API + CDN cache version.
|
||||
#
|
||||
# TODO: We're still saving outfit images for now, but we'll stop
|
||||
# doing that if this transition goes well!
|
||||
base_url = "https://impress-2020.openneo.net/outfits" +
|
||||
"/#{CGI.escape id.to_s}" +
|
||||
"/v/#{CGI.escape updated_at.to_i.to_s}"
|
||||
{
|
||||
large: "#{base_url}/600.png",
|
||||
medium: "#{base_url}/300.png",
|
||||
small: "#{base_url}/150.png",
|
||||
}
|
||||
|
||||
# NOTE: Below is the previous code that uses the saved outfits!
|
||||
# {}.tap do |versions|
|
||||
# versions[:large] = image.url
|
||||
# image.versions.each { |name, version| versions[name] = version.url }
|
||||
# end
|
||||
end
|
||||
|
||||
def closet_item_ids
|
||||
|
|
Loading…
Reference in a new issue