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 754215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:59:12+00:00 2026-05-14T14:59:12+00:00

I store user-uploaded images in the Google App Engine datastore as db.Blob , as

  • 0

I store user-uploaded images in the Google App Engine datastore as db.Blob, as proposed in the docs. I then serve those images on /images/<id>.jpg.

The server always sends a 200 OK response, which means that the browser has to download the same image multiple time (== slower) and that the server has to send the same image multiple times (== more expensive).

As most of those images will likely never change, I’d like to be able to send a 304 Not Modified response. I am thinking about calculating some kind of hash of the picture when the user uploads it, and then use this to know if the user already has this image (maybe send the hash as an Etag?)

I have found this answer and this answer that explain the logic pretty well, but I have 2 questions:

  1. Is it possible to send an Etag in Google App Engine?
  2. Has anyone implemented such logic, and/or is there any code snippet available?
  • 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-05-14T14:59:13+00:00Added an answer on May 14, 2026 at 2:59 pm

    Bloggart uses this technique. Have a look at this blog post.

    class StaticContentHandler(webapp.RequestHandler):
      def output_content(self, content, serve=True):
        self.response.headers['Content-Type'] = content.content_type
        last_modified = content.last_modified.strftime(HTTP_DATE_FMT)
        self.response.headers['Last-Modified'] = last_modified
        self.response.headers['ETag'] = '"%s"' % (content.etag,)
        if serve:
          self.response.out.write(content.body)
        else:
          self.response.set_status(304)
    
      def get(self, path):
        content = get(path)
        if not content:
          self.error(404)
          return
    
        serve = True
        if 'If-Modified-Since' in self.request.headers:
          last_seen = datetime.datetime.strptime(
              self.request.headers['If-Modified-Since'],
              HTTP_DATE_FMT)
          if last_seen >= content.last_modified.replace(microsecond=0):
            serve = False
        if 'If-None-Match' in self.request.headers:
          etags = [x.strip('" ')
                   for x in self.request.headers['If-None-Match'].split(',')]
          if content.etag in etags:
            serve = False
        self.output_content(content, serve)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a unique ID in php in order to store user-uploaded
I need to store the user's password in my iphone app. When posting an
I'm using nhibernate to store some user settings for an app in a SQL
I am attempting to use Filestream in sql server 2008 to store user uploaded
I'm using the System.Drawing classes to generate thumbnails and watermarked images from user-uploaded photos.
I need to store user entered changes to a particular table, but not show
Where do you store user-specific and machine-specific runtime configuration data for J2SE application? (For
I asked about Choosing a method to store user profiles the other day and
I'm a new Windows programmer and I'm not sure where I should store user
Is there an equivalent of the OS X Keychain, used to store user passwords,

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.