如何停止在电子邮件中缓存图像?

时间:2013-02-28 09:54:01

标签: c# email caching amazon

我正在使用c#和Amazon SES发送电子邮件。该电子邮件包含多个图像。当我第一次在我的客户端上打开该电子邮件时,它会加载来自主机的所有图像,但是当我第二次打开它时,似乎所有图像都已预先加载,我不想要这种行为。我知道这是因为缓存,但我怎么能强制不要缓存这些图像并每次从托管服务器重新加载。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

尝试在您的电子邮件图像目录中放置web.config文件。这应该指示电子邮件客户端(在请求图像时)不要缓存这些服务的图像(前提是所述电子邮件客户端正确实现HTTP协议)

<?xml version="1.0"?>
 <configuration>
  <location>
   <system.web>
    <authorization>
     <allow users="*" />
    </authorization>
   </system.web>
   <system.webServer>
    <httpProtocol>
    <customHeaders>
      <add name="Cache-Control" value="no-cache" />
    </customHeaders>
    </httpProtocol>
    <staticContent>
     <clientCache cacheControlMode="DisableCache" />
    </staticContent>
   </system.webServer>
  </location>
 </configuration>