Gmail的新图片缓存正在打破新闻稿中的图片链接 [英] Gmail's new image caching is breaking image links in newsletter

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

问题描述

我收到了一些自动发送的电子邮件,这些电子邮件是在我的网站注册完成后发送的。



直到最近,它们运行良好。现在和Amazon EC2上的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扩展名
    。 li>
  • 不要在图像url中使用任何类型的查询字符串,如?t = 34343

  • 您的图片必须包含png,jpg或gif作为扩展名。

  • 您的图片网址必须直接映射到您的图片上。

  • 如果您需要要为受保护的图片使用一些代理网址,那么您的回复必须包含正确的标题,如
    Content-Type:image / 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天全站免登陆