Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8389959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:51:44+00:00 2026-06-09T18:51:44+00:00

I have a simple rails app that stores images created by users in an

  • 0

I have a simple rails app that stores images created by users in an HTML5 site using canvasContext.toDataURL(). There’s an index action, which shows a list of thumbnails, and a show action for each image, showing the image.

I’m being absolutely lazy in the backend here, I just store the base64 encoded data:image/png;base64,... Strings of the original image and a thumbnail, which is also generated in the client. The images are included in the page using <img src="data:"/> URIs.

Now, since this isn’t fully supported in IE before v9, I will have to implement some kind of workaround, probably by including the URL of the generated image using a data- attribute and then replacing the source attribute after page load using jQuery.

This brings up the question whether it’s good practice to inline rather large images into HTML using data: URLs…

Are there any recommendations or best practices? The images might be up to 500 KiB, and each of them is used only once. The page containing the images will not change once created, so it should be cacheable pretty good, including the image. The index page containing the thumbnails (which are around 60 KiB) uses pagination, so the page will hardly be cacheable. You can assume that the HTML pages will be deflated or gzipped in production.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:51:46+00:00Added an answer on June 9, 2026 at 6:51 pm

    Best-practice is: Don’t.

    You’ll need a workaround anyway, which will completely duplicate the basic functionality, so you’ve just another place things can go wrong and more cases to test.

    You say the images should be very cacheable, but you’re sending them in a way that doesn’t allow you to include information about caching. However, with the more common approach of sending images over a separate HTTP request, you can send expires and max-age requests to indicate the image won’t change for a year. If you’re super-confident that the image won’t change you can also set a last-modified and an e-tag (you don’t even need any logic to decide on the etag, just send “IMMUTABLE” as the tag) and respond to every conditional GET by sending a 304 without even checking (because again, you only do that if you’re super-confident, otherwise though you can still implement a more conventional check for 304).

    If the image is just used once, then have the image served by something that creates it and writes it based on some identifying features in the query (just what is specific to what you are doing) and writes it to the stream to the browser. You’ll still have nicer separation within your application to have this done in its own place.

    Even with gzip, you aren’t going to beat this on stream size.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a simple rails app that has a people and a notes model.
I have a simple user registration page in my rails app that has two
I have a simple Rails 3.1 CRUD app built using Oracle running on JRuby.
I have a rails app that I've been testing on heroku, it's a simple
I have a simple rails app that I need to deploy on a Window
I have some simple jQuery that renders a page in my Rails app. Here's
I have a rails app that has some simple functionality, allowing the user to
So I have a rails app That lets users create lists and put items
I have a Ruby-on-Rails app that accepts a binary file upload, stores it as
I have a simple rails app that is like an event system which has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.