By hiagos93
I’m using Spaces to host image assets with small file sizes, hanging from 5kb to 50kb.
From what I’ve seen in the “Improve DO Spaces Performance” tutorial, this is an issue, but it doesn’t tell how to handle this situation and I had no luck searching on google.
I simple use <img src=“spaces-cdn-url-for-file”>.
How can I pack the images into some bigger files and make the web app unpack and use them?
PS: It’s a rails app.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
One of the main reasons to use webpack would be to decrease the number of requests to a CDN or web server to load images, but usually it’s not worth the overhead. With webpack the images are encoded in base64 strings and then inserted directly into the code where they are then rendered.
For your use case I would recommend that you just turn on the CDN option with your Spaces folder: Enable CDN for Spaces
And you should be good to go without having to worry about webpack.
With the CDN your images will be cached at the edge and will load quickly. Beyond that it’s usually overkill unless you are dealing with millions of requests.
I know this is old question. But in the past, I have placed the smaller images into a single image file then used javascript / CSS to move around in that image and only display the image I want. This seriously improved performance of my applications. In a single http request, all my images were pulled at once.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.