• Đăng ký
  • Đăng nhập

Cache-Control cho WordPress trên IIS

📅 — 👀 1935 — 👦

Trang này có hữu ích không?

👍 Có (15)        👎 Không (14)


Sau đây là code để thêm Cache-Control cho website, đoạn code này được lưu trong file web.config (cùng thư mục root của website)

Cache-Control cho phép một Client hoặc Server để truyền các chỉ thị đa dạng trong hoặc các yêu cầu hoặc các sự phản hồi. Những chỉ thị này có đặc trưng là có quyền ưu tiên cao hơn các thuật toán lưu vào bộ nhớ ẩn theo mặc định.

Thay địa chỉ https://thichcode.net/ thành địa chỉ website của bạn. cacheControlMaxAge="365.00:00:00" => lưu cache 365 ngày

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <remove name="Vary"></remove>
        <add name="Vary" value="Accept-Encoding"></add>
      </customHeaders>
    </httpProtocol>
    <staticContent>
      <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
    </staticContent>
    <rewrite>
      <rules>
        <rule name="WordPress: https://thichcode.net/" patternSyntax="Wildcard">
          <match url="*"/>
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
          </conditions>
          <action type="Rewrite" url="index.php"/>
	 </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

Trả lời


📁 Thủ thuật
🔖