Quantcast
Channel: Zenphoto forum
Viewing all articles
Browse latest Browse all 2917

Better image caching by browsers

$
0
0

I have a custom front end to Zenphoto and am trying to figure out the best way to get browsers and CDNs to permanently cache Zenphoto images.

This is important for me because I use a CDN to distribute the images to countries around the world. Right now the CDN can't cache images for very long at all, and going back to my Zenphoto instance significantly slows down the perceived load times for end users in distant locations. Also, CDNs use HTTP/2, which pipelines all those itty bitty thumbnails through a single HTTP connection, which makes it significantly faster. Most shared hosting services such as the type Zenphoto installations often run on do NOT support HTTP/2.

My Zenphoto web server can't serve the sized Zenphoto images with a far future expires header right now because any image could change at any moment (that's why I use Zenphoto, thanks!)

A common pattern to solve this is to request images using a URL that changes when the actual image changes. For example:

My <img src> URLs currently look like this:
mydomain.com/zenphoto/cache/my_album/my_photo_1024.jpg

I want them to look like this:
mydomain.com/zenphoto/cache/my_album/my_photo_1024.jpg?t=SOME_TIMESTAMP

... where SOME_TIMESTAMP is the timestamp of when the sized image or thumbnail was generated.

I don't see a way to get this through the API... am I missing something? I could go hunt for the file's last modified date on disk, but I'd much rather stay within the Zenphoto framework.

Thanks!


Viewing all articles
Browse latest Browse all 2917

Trending Articles