Report this

What is the reason for this report?

How to handle small files for DO's Spaces performance?

Posted on July 16, 2019

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.