Dynamic Images for email such as countdown clocks

2019-03-27 08:43发布

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?

1条回答
来,给爷笑一个
2楼-- · 2019-03-27 09:29

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.

查看更多
登录 后发表回答