我有一个drupal网站,我在其中显示带有自定义'查看器的PDF文件。我只使用PDF.js来确定PDF有多少页。
从S3加载PDF,CORS标头配置如下所示。但是PDF.js仍然无法通过CORS检查。
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<ExposeHeader>Accept-Ranges</ExposeHeader>
<ExposeHeader>Content-Encoding</ExposeHeader>
<ExposeHeader>Content-Length</ExposeHeader>
<ExposeHeader>Content-Range</ExposeHeader>
<AllowedHeader>Content-Type</AllowedHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
奇怪的是,当我打开Chrome开发工具时,在网络标签中我有“禁用缓存”功能。选择已启用。在这种情况下,S3使用上面显示的标题进行响应。
我无法理解缓存如何干预请求。似乎某种方式客户收到Status Code: 200 OK (from disk cache)
另外,我不知道如何在请求中翻译Provisional Headers are shown
消息
您可以在下面看到失败的PDF.js请求
一般
Request URL:http://s3.url.com/Filename.pdf
Request Method:GET
Status Code:200 OK (from disk cache)
Remote Address:54.118.21.153:80
Referrer Policy:no-referrer-when-downgrade
响应标头
Accept-Ranges:bytes
Content-Length:17937147
Content-Type:application/pdf
Date:Thu, 22 Feb 2018 08:04:40 GMT
ETag:"8a276af6cf75a601e8abd1890b5719f9"
Last-Modified:Thu, 09 Mar 2017 11:52:19 GMT
Server:AmazonS3
x-amzid2:qK1YpKCjkSkzRV14mQa/yzlqZwDxI6Fu2Mrk1AuD4ULHQ90MJup2UVjmsXUOed+dXiGU1CBsx2U=
x-amz-meta-cb-modifiedtime:Mon, 09 Jan 2017 18:42:46 GMT
x-amz-request-id:B49B5D464D8D115B
请求标题
*Provisional headers are shown
Origin:http://mywebsite.com
Referer:http://mywebsite.com/path/to/pdf.worker.js
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36