将与PHP扩展HTML的脚本标记脚本被缓存? [英] will a script in html's script tag with extension php be cached?
问题描述
例如<脚本类型=文/ JavaScript的SRC =资产/脚本/ somescript.php>< / SCRIPT>
将我的浏览器仍然只是通过不设置此脚本缓存这个报头meta标签缓存,必重新验证?
for example
<script type="text/javascript" src="assets/scripts/somescript.php"></script>
will my browser still cache this just by not setting this scripts headers meta tag cache to must-revalidate?
推荐答案
有些浏览器更具有侵略性比其他默认的缓存。不过,也有您可以发送指示何时重新加载$ C $ C缓存控制头。
Some browsers are more agressive with default caching than others. However, there are cache control headers you can send to indicate when to reload the code.
header("Expires: " . date("r", time() + ( 60 * 60 * 24 * 7 * 1 ) ) ); // Expires in 1 week
header("Content-Type: application/x-javascript");
是一个code-片段我已经知道使用。
Is a code-snippet I've been known to use.
您可以使用更花哨的东西,如若非-Modified头和ETag,而到期时间是消除额外的服务器调用唯一的。
You can use more fancy stuff like If-Not-Modified headers and ETags, but Expire times are the only ones that eliminate extra server calls.
这篇关于将与PHP扩展HTML的脚本标记脚本被缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!