[英]Change the cache-control time on Azure Website
我需要為Azure網站提供的一些靜態資源增加Cache-control
標頭的時間。 我使用PHP作為語言。
我可以為整個文件夾執行此操作嗎? 我可以為一些文件擴展(.jpg)嗎?
通常,您可以使用簡單的.htaccess
執行此操作,但我不知道如何在Azure網站中執行此操作。
我不想使用CDN請不要回答。
Azure網站使用IIS配置。 要配置Cache-control
標頭,請創建一個名為web.config
的文件(或更新您可能已經擁有的文件)並將其放入其中
例如,這將max-age
為20天
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="20.00:00:00" />
</staticContent>
</system.webServer>
</configuration>
如果你想要一個特定日期,你可以這樣做,這將使它在2016年8月1日到期
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseExpires" httpExpires="Mon, 01 Aug 2016 00:00:00 GMT" />
</staticContent>
</system.webServer>
</configuration>
有關IIS中clientCache
設置的更多信息,請查看此頁面http://www.iis.net/configreference/system.webserver/staticcontent/clientcache
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.