问题
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