你如何匹配的Apache的ETAG? [英] How do you make an etag that matches Apache?

查看:252
本文介绍了你如何匹配的Apache的ETAG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要让符合什么阿帕奇产生ETAG。它怎么阿帕奇创建的ETag的?

I want to make an etag that matches what Apache produces. How does apache create it's etags?

推荐答案

Apache使用的inode,文件大小,修改时间的标准格式。唯一需要注意的情况是,该修改时间必须是划时代的时间和补零所以它是16位。这里是如何做到这一点在PHP中:

Apache uses the standard format of inode-filesize-mtime. The only caveat to this is that the mtime must be epoch time and padded with zeros so it is 16 digits. Here is how to do it in PHP:

$fs = stat($file);
header("Etag: ".sprintf('"%x-%x-%s"', $fs['ino'], $fs['size'],base_convert(str_pad($fs['mtime'],16,"0"),10,16)));

这篇关于你如何匹配的Apache的ETAG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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