W3TC Page Cache Disk: Enhanced

serve the cached pages for logged in subscribers

However, if you want to disable cache for specific logged in users and serve the cached pages for logged in subscribers, you should disable the “Don’t cache pages for logged in users” option, enable the “Don’t cache pages for following user roles” option and select all user roles except “Subscriber”, save all settings and purge the cache.

https://wordpress.org/support/topic/dont-cache-for-logged-in-users/

.htaccess

RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]

wordpress_logged_in がロールごとの w3tc_logged_xxx に変わる

RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|w3tc_logged_6b058f84be6f8456baaf7da16101ff7e|w3tc_logged_c2be9cf11320b701ddad1bf186f554eb|w3tc_logged_f215454a92c1040a1f7678f7efca69a5|w3tc_logged_2c9572fb7aac4f4edafcdc1530628ef4|wptouch_switch_toggle) [NC]

この cookie 発行は要再ログイン

Page Cache Advanced

Maximum lifetime of cache objects: 3600 seconds
Garbage collection interval: 3600 seconds

Garbage collection interval ごとにチェック Maximum lifetime of cache objects をすぎたファイルを削除

確認

find wp-content/cache/page_enhanced/example.com/ -type f -ls
find wp-content/cache/page_enhanced/example.com/ -type f ! -name '*_old' -ls
find wp-content/cache/page_enhanced/example.com/ -type f -mmin +120 -ls

-mmin +120 120分以上前に更新

Accepted query strings:

gad_source wbraidを追加
設定として保存されている。w3tcのデフォルトが更新された場合は Add Defaults で追加できる

広告パラメータ

LINE

管理画面の[トラッキング(LINE Tag)]>[トラッキング]を[オン]に設定された状態で配信すると、
「ldtag_cl=XXXXXXXXXXXXXXXXXXXXXXXX_oa<_r=XXX_oa」という形式のパラメーターが自動的に付与されます。
よくあるご質問 | LINE for Business

  • ldtag_cl
  • lt_r

Never cache the following pages

ログインURLをwp-login.phpから変更した場合は、変更したURLを追加する

wp-cli 個別ページのキャッシュ削除

https://wordpress.org/support/topic/i-want-to-purge-a-single-page-with-wp-w3-total-cache-flush/

トップページのみキャッシュ削除

wp w3-total-cache flush post --permalink=https://example.com/

確認

watch -n 1 ls wp-content/cache/page_enhanced/example.com/_index_slash_ssl.html*

help

$ wp help w3-total-cache flush
...
SYNOPSIS

  wp w3-total-cache flush <cache> [--post_id=<id>] [--permalink=<post-permalink>]

OPTIONS
  <cache>
    Cache to flush
    all         Flush all caches
    posts       Flush posts (pagecache and further)
    post        Flush the page cache
    database    Flush the database cache
    db          Flush the database cache
    object      Flush the object cache
    minify      Flush the minify cache

  [--post_id=<id>]
    Flush a specific post ID

  [--permalink=<post-permalink>]
    Flush a specific permalink