class ImageHandler(webapp2.RequestHandler):
def get(self):
a_user = db.get(self.request.get('img_id'))
if a_user.profile_img:
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(a_user.profile_img)
else:
self.response.out.write("No image")
This is quite slow when loading a image. Every time when I reload a page I see the images reloading starting from top of the image and gradually load the whole image (Please let me know if you don’t understand what I mean). Should I cache the img_id? but it seems to me that when you use a handler to load an image, it doesn’t help for the application to load faster image. Any ideas on how to load image faster? Thanks in advance.
Are you still in development? Things will be much slower in the development server, as that only processes one request at a time. The production performance will be much better.
That said, you might be better off using GAE’s built-in image hosting. For that, rather than storing the image data in a blobproperty within your model, you upload it directly to the blobstore and reference it with a
BlobReferenceProperty. Once that’s done, you can useImage.get_serving_url()to get GAE to serve it directly, so it doesn’t have to go through your app at all.