Gmail 的新图像缓存正在破坏简报中的图像链接 [英] Gmail's new image caching is breaking image links in newsletter

查看:33
本文介绍了Gmail 的新图像缓存正在破坏简报中的图像链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站注册完成后会自动发送一些电子邮件.

直到最近,它们都运行良好.现在 和 Ubuntu 服务器,但我不确定与问题相关.

解决方案

我想我已经解决了 GoogleImageProxy 问题.

这与 CACHING 概念有关.假设您最近在服务器上部署了 php 代码,但忘记上传图片.你用你的电子邮件逻辑测试过一次.您的系统生成了一封 HTML 电子邮件.当这封电子邮件到达 gmail 服务器时,GoogleImageProxy 将尝试从您的站点获取图像并将其存储到其自己的代理服务器.在获取图像时,GoogleImageProxy 发现您丢失的图像有一些 404 状态,一些受保护图像有 403 状态.GoogleImagesProxy 已将这些状态存储到其自己的代理服务器中.

现在尝试打开您的电子邮件,您注意到您的图像有一些 404 状态.这是可以理解的事情.您立即意识到您忘记上传一些图像,因此您将它们上传到您的服务器.并且您还修复了一些针对受保护图像的权限.

你现在已经完成了.现在您尝试再次运行您的 php-email 脚本.因此,您会在 Gmail 或 Hotmail 收件箱中收到另一封电子邮件.您已经解决了图像的所有问题.现在图像必须显示在您的电子邮件内容中.但您仍然无法看到图像.

啊,可能你忘记清除浏览器的缓存了.清除浏览器的缓存并再次加载 gmail 或 hotmail 页面.但结果还是一样.尝试应用数十个修复程序/补丁并尝试运行您的 php-email 脚本数千次.但结果还是一样.没有改善.

真正的问题

这到底是怎么回事?让我给你解释一下.转到您的访问日志并尝试查找来自 GoogleImageProxy 的请求.您会惊讶地发现,根据电子邮件中使用的不同图像的数量,来自 GoogleImageProxy 的请求只有 2 或 3 个.GoogleImageProxy 从不尝试获取图像,即使您通过上传丢失的图像并设置受保护图像的权限来解决图像问题.为什么?清除浏览器的缓存没有任何影响.GoogleImageProxy 永远不会为您的新电子邮件获取新图像,因为图像现在与最后的状态代码一起缓存到 GoogleImageProxy 中,而不是缓存在您自己的浏览器中.

GoogleImageProxy 已为图像设置了自己的到期日期.我想一个月.所以现在图像的新副本将在到期日期后获取.我是说一个月后.您不能强制 GoogleImageProxy 获取图像.但是在电子邮件中显示图像对您来说很重要.有什么解决办法?

解决方案

以下是强制 GoogleImageProxy 获取您的图像的唯一方法

  • 使用 png、jpg 或 gif 扩展名将您的图像重命名为其他名称仅.
  • 不要在图片网址中使用任何类型的查询字符串,例如 ?t=34343
  • 您的图片必须包含 png、jpg 或 gif 作为扩展名.
  • 您的图片网址必须直接映射到您的图片上.
  • 如果您需要为受保护的图像使用一些代理 url,那么您的响应必须包含正确的标头,例如内容类型:图像/jpeg
  • 文件扩展名和内容类型标头必须匹配
  • 状态码必须是 200 而不是 403、500 等

重要提示

尝试为每次运行 php-email 脚本重复整个过程.因为每次 GoogleImageProxy 都会缓存您的图片,而您每次尝试都必须重复相同的过程.

希望这能解决大多数人的问题.

I've got some automatic emails that are sent out upon signup completion for my site.

Until recently, they worked fine. Now Google's new system is rewriting the images and storing them in it's cache (supposedly)

However, Google's new rewriting of my image links are completely breaking them, giving a 500 error and a broken link image.

Lets say my normal image url is:

http://www.mysite.com/images/pic1.jpg

Google is rewriting this to:

https://ci5.googleusercontent.com/proxy/vI79kajdUGm6Wk-fjyicDLjZbCB1w9NfkoZ-zQFOB2OpJ1ILmSvfvHmE56r72us5mIuIXCFiO3V8rgkZOjfhghTH0R07BbcQy5g=s0-d-e1-ft#http://www.mysite.com/images/pic1.jpg

However, there is nothing at that URL.

So, either there is something wrong with the links that are being created by Google or the images are just not being uploaded to the googleusercontent server, but I have no idea how to solve the issue.

Im using PHP, the phpmailer library and a Ubuntu server on Amazon EC2, but Im not sure that is related to the issue.

解决方案

I think I have figured out the GoogleImageProxy issue.

This is something related to CACHING concept. suppose, you have recently deployed your php code on your server but you forgot to upload images. you tested once with your email logic. your system generated an HTML email. When this email will hit the gmail server GoogleImageProxy will try to fetch and store the images from your site to its own proxy server. while fetching the images, GoogleImageProxy found some 404 statuses against your missing images and 403 against some protected images. GoogleImagesProxy has stored these statuses into its own proxy server.

Now tried to open your email, you noticed some 404 statuses against your images. This is something understandable. You immediately realized that you forgot to upload some images, so you uploaded them to your server. and also you have fixed some permissions against protected images.

You are all done now. Now you try to run your php-email script once again. As a result you receive another email in your Gmail or Hotmail inbox. you had fixed all the issues with your images. Now the images must be displayed in your email content. but you are still unable to see the images.

Ah, possibly you forgot to clear your browser's cache. Clear your browser's cache and load the gmail or hotmail page once again. But the result will be still the same. Try to apply dozens of fixes/patches and try to run your php-email script a thousands time. But the result will be still the same. No improvement.

THE REAL PROBLEM

What the hell is going on? Let me explain it to you. Go to your access log and try to find requests from GoogleImageProxy. You'll be surprised to see that there will be only 2 or 3 three requests from GoogleImageProxy depending on the number of different images used in your email. GoogleImageProxy never tried to fetch images Even after you have fixed the issues with your images by uploading missing images and setting permissions for protected images. Why? Clearing your browser's cache has no impact. GoogleImageProxy will never fetch the fresh images even for your newer email because the images are now cached into GoogleImageProxy along with their last status code and not cached in your own browser's.

GoogleImageProxy has set its own expiry date for the images. I think one month. so now the fresh copy of images will be fetch after expiry date. I mean after one month. You can not force GoogleImageProxy to fetch the images. But its important for you to display images in your email. What can be the solution?

THE SOLUTION

Following is the only way to force GoogleImageProxy to fetch your images

  • Rename your images to something else with png, jpg or gif extensions only.
  • Don't use any kind of query string in your image url like ?t=34343
  • your image must include png, jpg or gif as an extension.
  • your image url must be mapped onto your image directly.
  • If you need to use some proxy url for your protected images then your response must include the proper header like Content-Type: image/jpeg
  • File extension and content-type header must match
  • Status-code must be 200 instead of 403, 500 etc

IMPORTANT NOTE

Try to repeat the whole process for every run of php-email script. because every time GoogleImageProxy will cache your images and you'll have to repeat the same process for every new try.

Hopefully this will fix the issue for most of the people.

这篇关于Gmail 的新图像缓存正在破坏简报中的图像链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆