<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:media="http://search.yahoo.com/mrss/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>快取 &#8211; 馬修 IT</title>
	<atom:link href="https://blog.ocam.live/archives/tag/%e5%bf%ab%e5%8f%96/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.ocam.live</link>
	<description>生活中所接觸各種電腦及網路問題與懷舊模擬器的專業問題解決與新資訊介紹的網站</description>
	<lastBuildDate>Fri, 05 Dec 2025 09:59:07 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blog.ocam.live/wp-content/uploads/2025/03/cropped-logo-1-300x300.png</url>
	<title>快取 &#8211; 馬修 IT</title>
	<link>https://blog.ocam.live</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>減少 AI 爬蟲對 WordPress 的影響建議增加 Cloudflare 快取設定</title>
		<link>https://blog.ocam.live/archives/4613</link>
		
		<dc:creator><![CDATA[blog.ocam.live]]></dc:creator>
		<pubDate>Fri, 05 Dec 2025 09:59:04 +0000</pubDate>
				<category><![CDATA[IT 日常]]></category>
		<category><![CDATA[cloudflare]]></category>
		<category><![CDATA[快取]]></category>
		<guid isPermaLink="false">https://blog.ocam.live/?p=4613</guid>

					<description><![CDATA[近一兩年來由於 AI 熱潮愈來愈多的 AI 爬蟲機器人影響各網站的主機效能。由其是那種便宜的 VPC 主機，隨 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">近一兩年來由於 AI 熱潮愈來愈多的 AI 爬蟲機器人影響各網站的主機效能。由其是那種便宜的 VPC 主機，隨便 AI 一 爬 CPU 馬上飆升影響正常人的瀏覽，而且台灣的某些主機商有主機資源限制的會直接噴 Resource Limit Is Reached 。你會以為太多人來看網頁但實際去 GA4 看又看不出流量有增長的樣子。這就是典型機器人爬蟲。這篇文章就是要教你如何用較簡單的方式來對付機器人。</p>



<h2 class="wp-block-heading">一：使用 Cloudflare 阻擋  AI BOT 功能。</h2>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/12/cf_block_ai_bot_settings-1024x544.png" alt="cf block ai bot settings" class="wp-image-4617" title="減少 AI 爬蟲對 Wordpress 的影響建議增加 Cloudflare 快取設定"></figure>



<h2 class="wp-block-heading">二：按裝一個快取外掛(只要一個不要多裝。會相互影響)</h2>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">1. <strong>WP Super Cache</strong></h4>



<ul class="wp-block-list">
<li>Automattic 官方出品</li>



<li>產生靜態 HTML，效能穩定</li>



<li>簡單易用、設定快速</li>



<li>適用：共用主機、一般網站</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">2. <strong>W3 Total Cache (W3TC)</strong></h4>



<ul class="wp-block-list">
<li>功能最完整的快取外掛之一</li>



<li>支援 Page Cache、Object Cache、Database Cache、Minify</li>



<li>可整合 CDN</li>



<li>適用：需要高度客製化的網站</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">3. <strong>WP Fastest Cache</strong></h4>



<ul class="wp-block-list">
<li>界面簡單，效果顯著</li>



<li>支援 Minify、瀏覽器快取、合併 CSS/JS</li>



<li>Pro 版可支援圖片壓縮、Mobile Cache</li>



<li>適用：不想複雜設定的使用者</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">4. <strong>LiteSpeed Cache (LSCWP)</strong></h4>



<ul class="wp-block-list">
<li>若主機使用 LiteSpeed Web Server，效能頂尖</li>



<li>全站快取、Object Cache、圖片優化、CDN</li>



<li>一站式網站加速方案</li>



<li>適用：LiteSpeed 主機、Cloudways、cPanel LiteSpeed</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">5. <strong>Cache Enabler</strong></h4>



<ul class="wp-block-list">
<li>由 KeyCDN 開發</li>



<li>輕量級快取外掛</li>



<li>支援 WebP、自動清除快取</li>



<li>適用：希望快取外掛越簡單越好</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">6. <strong>Hummingbird Performance</strong></h4>



<ul class="wp-block-list">
<li>Page Cache + 檔案壓縮 + 資源優化</li>



<li>有效提升 GTmetrix / PageSpeed 分數</li>



<li>與 Smush 圖片壓縮搭配效果更佳</li>



<li>適用：需要完整站點優化工具</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">7. <strong>Comet Cache</strong></h4>



<ul class="wp-block-list">
<li>前身為 ZenCache</li>



<li>自動快取清除、自動版控</li>



<li>安裝即可用，設定簡單</li>



<li>適用：一般中小型網站</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">8. <strong>Breeze (Cloudways)</strong></h4>



<ul class="wp-block-list">
<li>Cloudways 官方快取</li>



<li>支援 Varnish、Minify、Gzip</li>



<li>適用：使用 Cloudways Hosting 的網站</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">9. <strong>NitroPack</strong>（加速服務）</h4>



<ul class="wp-block-list">
<li>雲端加速，不只快取</li>



<li>自動優化 CSS/JS、lazy load、CDN</li>



<li>快但過度優化可能影響 Lighthouse 分析</li>



<li>適用：需要“一鍵加速”的網站</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h4 class="wp-block-heading">推薦搭配方式</h4>



<ul class="wp-block-list">
<li><strong>LiteSpeed 主機 → LiteSpeed Cache</strong></li>



<li><strong>一般虛擬主機 → WP Super Cache / WP Fastest Cache</strong></li>



<li><strong>需要極高自訂 → W3 Total Cache</strong></li>



<li><strong>只要小巧快速 → Cache Enabler</strong></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph">個人習慣 <strong>WP Fastest Cache</strong> 。快取多半大同小異不用特別研究。號稱最快的也快不了多少。主機快硬碟快較實在。</p>



<h2 class="wp-block-heading">三：Cloudflare Cache Rule 快取規則。</h2>



<p class="wp-block-paragraph">這個設定主要是用來對付專門直抓 API 的。wordpress 預設是有開放的。那些 AI 商也都知道直接抓 API 回傳的 XML 方便 AI 處理。如下</p>



<ul class="wp-block-list">
<li>/wp-json/wp/v2/posts/186428</li>



<li>/wp-json/oembed/1.0/embed?url=</li>
</ul>



<p class="wp-block-paragraph">但是這些 API 在預設的快取模組上並不會主動作快取的動作。也就是每一次 CALL API 的都需要 PHP / MYSQL 作大量的運算然後回傳結果給 AI 。這也是在主機上已封機器人後還 CPU 爆增的可能原因之一。</p>



<p class="wp-block-paragraph">在 Cloudflare 管理介面 Caching -> Cache Rules 增加規則</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/12/cf_cache_rule_01-1024x596.png" alt="cf cache rule 01" class="wp-image-4619" title="減少 AI 爬蟲對 Wordpress 的影響建議增加 Cloudflare 快取設定"></figure>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.ocam.live/wp-content/uploads/2025/12/cf_cache_rule_02-1024x530.png" alt="cf cache rule 02" class="wp-image-4620" title="減少 AI 爬蟲對 Wordpress 的影響建議增加 Cloudflare 快取設定"></figure>



<p class="wp-block-paragraph">其中 TTL 視自已的情況設定。通常如文章不會經常改的可設定大一點，如 1 個月。</p>
]]></content:encoded>
					
		
		
		<media:content url="https://blog.ocam.live/wp-content/uploads/2025/12/cloudflare_cache_logo.jpg" medium="image"></media:content>
            	</item>
		<item>
		<title>WordPress 當文章存檔或更新時也想刪除其它頁面的快取要如何處理？</title>
		<link>https://blog.ocam.live/archives/4117</link>
		
		<dc:creator><![CDATA[blog.ocam.live]]></dc:creator>
		<pubDate>Fri, 20 Jun 2025 00:52:00 +0000</pubDate>
				<category><![CDATA[程式設言]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[快取]]></category>
		<guid isPermaLink="false">https://blog.ocam.live/?p=4117</guid>

					<description><![CDATA[在 WordPress 外掛 WP Fastest Cache 中，「刪除快取」的條件與機制主要依據以下幾個情 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">在 WordPress 外掛 <strong>WP Fastest Cache</strong> 中，「刪除快取」的條件與機制主要依據以下幾個情況觸發，這些條件可分為「手動刪除」與「自動刪除」兩大類：</p>



<h3 class="wp-block-heading">一、手動刪除快取的條件</h3>



<p class="wp-block-paragraph">這是由網站管理者在後台主動操作的：</p>



<ol class="wp-block-list">
<li><strong>清除全部快取（Delete Cache）</strong>
<ul class="wp-block-list">
<li>清除 <code>wp-content/cache/all/</code> 中的所有快取檔案。</li>



<li>包括 HTML 快取、CSS/JS 合併檔案等。</li>
</ul>
</li>



<li><strong>清除快取和已合併的 CSS/JS（Delete Cache and Minified CSS/JS）</strong>
<ul class="wp-block-list">
<li>除了快取 HTML 檔，連同 <code>wp-content/cache/wpfc-minified/</code> 的檔案也一併清除。</li>
</ul>
</li>
</ol>



<h3 class="wp-block-heading"> 二、自動刪除快取的條件</h3>



<p class="wp-block-paragraph">這些是由 WP Fastest Cache 自動根據某些觸發事件來刪除快取的情況：</p>



<h4 class="wp-block-heading">1. <strong>發表或更新文章/頁面時</strong></h4>



<ul class="wp-block-list">
<li>預設會清除與該文章有關的快取（如：該文章本身、首頁、分類頁、標籤頁等）。</li>
</ul>



<h4 class="wp-block-heading">2. <strong>留言新增或審核通過時</strong></h4>



<ul class="wp-block-list">
<li>新增留言時，會刪除該文章的快取。</li>
</ul>



<h4 class="wp-block-heading">3. <strong>選用「定期清除快取」功能</strong></h4>



<ul class="wp-block-list">
<li>外掛提供定時清除快取的功能（例如每小時、每天）。</li>



<li>可以在外掛設定中設定清除頻率。</li>
</ul>



<h4 class="wp-block-heading">4. <strong>使用者自定義排程（若開發者透過程式碼設定）</strong></h4>



<ul class="wp-block-list">
<li>可使用 <code>wpfc_delete_cache()</code> 這類函式透過 PHP 呼叫來手動清除特定快取。</li>



<li>也可用 <code>do_action('wpfc_clear_cache')</code> 來觸發清除事件。</li>
</ul>



<h2 class="wp-block-heading">問題：無法自由刪除任意快取</h2>



<p class="wp-block-paragraph">在網站的實務上有時需要在特定條件下刪除特定頁面的快取。但上述的方法皆不適合。因為一但清除全部的快取時網站會有一段時間除了 cpu 會變較高之外頁面讀取的反應也會變慢。這時就要針對特定條件下增加一下自定的  function 來處理。如程式所列</p>



<pre class="wp-block-code"><code>//由於快取關系，更新文章不會自動更新此頁。故用此function 在文章存檔後刪此頁快取
function delete_specific_cache_file_on_post_save($post_id) {
    // 避免自動儲存觸發
    if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) {
        return;
    }

    // 設定快取檔案路徑
    $cache_file = WP_CONTENT_DIR . '/cache/all/2025-fifa-cwc/index.html';

    // 如果檔案存在且是檔案，就刪除它
    if (file_exists($cache_file) &amp;&amp; is_file($cache_file)) {
            @unlink($cache_file); // 刪除 index.html
            error_log("deleted 2025-fifa-cwc",0);//記錄。可拿掉
    }
}
add_action('save_post', 'delete_specific_cache_file_on_post_save', 10, 3);
</code></pre>



<p class="wp-block-paragraph">把這程式寫進子主題的 function.php 就可以在編寫文章更新或存檔時也額外刪除另一個頁面的快取</p>


<div class="wp-block-stackable-heading stk-block-heading stk-block-heading--v2 stk-block stk-7280d78" id="x-68000-games-supporting" data-block-id="7280d78"><h2 class="stk-block-heading__text">延伸閱讀</h2></div><div class="reading-grid"><a href="https://blog.ocam.live/archives/3670" class="card">
      <img fetchpriority="high" decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/04/Mysql_logo-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="MySQL logo" title="Wordpress 當文章存檔或更新時也想刪除其它頁面的快取要如何處理？">
      <div class="card-content">
        <div class="card-title">有效率的學習 MySQL</div>
      </div>
		</a><a href="https://blog.ocam.live/archives/3403" class="card">
      <img decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/04/Blocksy-Free-1-300x300.jpg" class="attachment-thumbnail size-thumbnail" alt="如何在 Blocksy Free 的版本使用自定字型" title="Wordpress 當文章存檔或更新時也想刪除其它頁面的快取要如何處理？">
      <div class="card-content">
        <div class="card-title">如何在 Blocksy Free 的版本使用自定字型</div>
      </div>
		</a><a href="https://blog.ocam.live/archives/4040" class="card">
      <img decoding="async" width="300" height="300" src="https://blog.ocam.live/wp-content/uploads/2025/05/duck-dns-300x300.webp" class="attachment-thumbnail size-thumbnail" alt="Duck DNS feature image" title="Wordpress 當文章存檔或更新時也想刪除其它頁面的快取要如何處理？">
      <div class="card-content">
        <div class="card-title">免費的 DDNS Duck DNS 簡單快速設定方式</div>
      </div>
		</a></div></ul>
]]></content:encoded>
					
		
		
		<media:content url="https://blog.ocam.live/wp-content/uploads/2025/06/wordpress_function_delete_antoher_page_cache_file.jpg" medium="image"></media:content>
            	</item>
	</channel>
</rss>
