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

前提是你 提交于 2020-01-10 18:44:48

问题


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:


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.



来源:https://stackoverflow.com/questions/21802820/dynamic-images-for-email-such-as-countdown-clocks-in-light-of-gmail-image-cachi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!