Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Images for email such as countdown clocks (in light of gmail image caching)

What I am trying to do: A dynamic countdown clock in the body of an email

What is causing me pain: Google's decision to cache images for users of the gmail client

I implemented an email countdown clock for my company last November using this technique:

Countdown Timer Image GIF in Email

Worked like a charm, however in December, a major monkey wrench was thrown by Google when they decided to cache all images for people using Gmail clients.

http://kickdynamic.com/update-on-the-gmail-image-change/

So the problem affects all people on gmail clients that open an email a second time. They will see a cached image. For something like a countdown clock, this would cause a lot of harm.

Admittedly this is somewhat of a blind distress call, but has anyone figured out how to do a email countdown clock that is unaffected by google's image caching?

like image 499
dt-dev-person Avatar asked Feb 15 '14 19:02

dt-dev-person


People also ask

Does Gmail cache images?

Without individual tracking, Gmail will cache the image/pixel in your tracking code along with all the other images in your email, and serve the same tracking image for all recipients of your email. This means that only the first open using that tracking code will be recorded and you'll see very few opens for Gmail.

What is a Google cached image?

Like other web browsers, Google Chrome features a cache that stores files such as images, scripts and video content from websites that you visit over time.


1 Answers

I had the same problem. So with the following headers, I disabled image caching and it works in Gmail too (therefore Gmail Image Proxy respects the cache headers):

header('Content-Type: image/jpeg');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

Credits to this library note.

like image 52
Jordan Enev Avatar answered Oct 21 '22 12:10

Jordan Enev