Skip to content

Repository files navigation

Digits Cache Compat

Restores WordPress page caching when Digits breaks it with DONOTCACHEPAGE.

Built by WebiLoper · Telegram: @webiloper · GitHub: @mhghazi82

فارسی را از اینجا بخوانید ↓


The problem

Digits is a popular WordPress mobile login / OTP plugin. Internally it often defines:

define( 'DONOTCACHEPAGE', true );

That constant is a WordPress convention meaning “do not cache this page.”

Digits sets it in places that run far too broadly, including:

  1. digits_login() on every wp_loaded request — before checking whether ?login= / ?logout= is even present
  2. logout_url filter — even when Digits returns the original logout URL unchanged
  3. Footer login modals / forms — while rendering nonces in the HTML

If Digits is active and a page cache plugin respects DONOTCACHEPAGE, your entire public site can become uncacheable.
With LiteSpeed Cache you may see logs like:

❌ forced no cache [reason] DONOTCACHEPAGE const

That destroys TTFB / PageSpeed gains on otherwise cacheable pages.


The solution

Digits Cache Compat fixes this in two layers:

1) Digits source guard (root-cause fix)

Stops Digits from defining DONOTCACHEPAGE on every front-end bootstrap and every logout link render.
This helps all page cache plugins.

2) Official cache bridges

For cache plugins that expose an override API, this plugin tells them to ignore Digits’ constant on safe public pages.

Login, logout, Digits form/account pages, and WooCommerce cart/checkout/my-account stay uncached by design.


Who is this for?

Any WordPress site that uses:

  • Digits (mobile signup / login), and
  • A page cache plugin (LiteSpeed Cache, WP Rocket, W3 Total Cache, Hummingbird, Cache Enabler, WP Super Cache, WP Fastest Cache, SiteGround Speed Optimizer, Breeze, …)

If Digits made your cache “mysteriously stop working,” this plugin is for you.


Features

  • Digits source guard (fixes the wp_loaded + logout_url poison)
  • Bridges for LiteSpeed Cache, WP Rocket, FlyingPress, W3 Total Cache, Hummingbird, Cache Enabler
  • Extra help for WP Super Cache, WP Fastest Cache, SiteGround, Breeze via source guard
  • Safe exclusions for Digits auth flows, Digits form pages, WooCommerce, and wp-login.php
  • Custom URL exclude fragments
  • Clean settings UI with help for every section
  • English + Persian (FA) admin translations + RTL layout
  • Developer filters
  • No Digits core file patches (survives Digits updates)

Supported cache plugins

Plugin Support level
LiteSpeed Cache Full bridge
WP Rocket Full bridge
FlyingPress Full bridge
W3 Total Cache Full bridge
Hummingbird Full bridge
Cache Enabler Full bridge
WP Super Cache Helped by source guard
WP Fastest Cache Helped by source guard
SiteGround Speed Optimizer Helped by source guard
Breeze Helped by source guard

Requirements

  • WordPress 5.8+
  • PHP 7.4+
  • Digits
  • A page cache plugin

Installation

  1. Download this repository as ZIP or clone it:
git clone https://github.com/mhghazi82/digits-cache-compat.git
  1. Upload the digits-cache-compat folder to wp-content/plugins/
  2. Activate Digits Cache Compat in Plugins
  3. Open Settings → Digits Cache Compat
  4. Keep defaults enabled (Compatibility + Source guard)
  5. Purge your page cache once
  6. Visit a public page as a logged-out guest and confirm cache HIT/MISS

Verify with LiteSpeed Cache

  1. Open a normal public page twice while logged out
  2. Expect headers like X-LiteSpeed-Cache: hit or miss
  3. Digits login URLs (?login=true) and WooCommerce checkout should remain uncached

Settings explained

1) Core compatibility

  • Enable compatibility — master on/off switch
  • Digits source guard — recommended root-cause fix for all caches

2) Cache plugin bridges

Enable the bridge for the cache plugin you use. Leaving unused bridges on is usually harmless.
Bridges also cover late Digits defines (for example footer login modals).

3) Safety exclusions

Pages this plugin will not force back into cache:

  • Digits form / account pages
  • WooCommerce cart, checkout, my-account
  • wp-login.php
  • Custom URL fragments you list
  • Always: Digits ?login= / ?logout= / ?lnounce=

4) Developer tools

  • Admin bar decision indicator
  • Optional debug.log tracing when WP_DEBUG is on

What stays uncached (by design)

Request Behavior
?login= / ?logout= / ?lnounce= Always uncached
Digits form / account pages Uncached (default)
WooCommerce cart / checkout / account Uncached (default)
wp-login.php Uncached (default)
Custom exclude paths Uncached
Admin / AJAX / REST / cron / non-GET Uncached

Your cache plugin’s own rules (logged-in users, cookies, private cache, excludes) still apply.


Developer API

add_filter( 'digits_cache_compat_should_allow_cache', function( $allow, $reason ) {
    // Return false to keep Digits' DONOTCACHEPAGE in effect.
    return $allow;
}, 10, 2 );

add_filter( 'digits_cache_compat_force_nocache', '__return_true' );

add_action( 'digits_cache_compat_register_bridges', function( $bridges ) {
    // Register another cache bridge.
} );

Important notes

  • Do not globally define DONOTCACHEPAGE as false early. Some caches treat any definition as no-cache, and WooCommerce needs the constant on cart/checkout.
  • This plugin does not patch Digits core files.
  • Not affiliated with Digits / UnitedOver or LiteSpeed Technologies.

Support


Changelog

See CHANGELOG.md.


License

GPL-2.0-or-later. See LICENSE.


فارسی — سازگاری کش دیجیتس

وقتی افزونه دیجیتس با DONOTCACHEPAGE کش سایت وردپرس را از کار می‌اندازد، کش صفحات را برمی‌گرداند.

ساخته‌شده توسط WebiLoper · تلگرام: @webiloper


مشکل چیست؟

افزونه Digits برای ورود و ثبت‌نام با موبایل/OTP خیلی رایج است. داخل کد آن بارها این ثابت تعریف می‌شود:

define( 'DONOTCACHEPAGE', true );

معنی این ثابت برای افزونه‌های کش این است: «این صفحه را کش نکن.»

دیجیتس این کار را در جاهایی انجام می‌دهد که خیلی گسترده‌اند، از جمله:

  1. تابع digits_login() روی هر درخواست wp_loaded — حتی قبل از اینکه چک کند آیا واقعاً صفحه لاگین است یا نه
  2. فیلتر logout_url — حتی وقتی لینک خروج را عوض نمی‌کند
  3. مودال/فرم لاگین در فوتر صفحات

نتیجه: اگر LiteSpeed Cache، WP Rocket یا کش مشابهی فعال باشد، ممکن است کل سایت عمومی از کش خارج شود و سرعت افت کند.

در لاگ LiteSpeed معمولاً چنین چیزی دیده می‌شود:

❌ forced no cache [reason] DONOTCACHEPAGE const

راه‌حل این افزونه

سازگاری کش دیجیتس (Digits Cache Compat) مشکل را در دو لایه حل می‌کند:

۱) محافظ منبع دیجیتس (اصلاح ریشه‌ای)

جلوی تعریف بی‌مورد DONOTCACHEPAGE در هر بارگذاری صفحه و هر لینک خروج را می‌گیرد.
این بخش به همه افزونه‌های کش کمک می‌کند.

۲) بریج رسمی افزونه‌های کش

برای کش‌هایی که API دارند، روی صفحات عمومیِ امن به آن‌ها می‌گوید ثابت دیجیتس را نادیده بگیرند.

صفحات لاگین/خروج دیجیتس، فرم‌های دیجیتس، و سبد/تسویه/حساب ووکامرس عمداً بدون کش می‌مانند.


برای چه کسانی است؟

هر سایت وردپرسی که هم‌زمان دارد:

  • افزونه دیجیتس، و
  • یک کش صفحه (لایت‌اسپید، راکت، W3TC و …)

اگر حس می‌کنید «کش کار نمی‌کند و نمی‌دانم چرا»، و دیجیتس نصب است، احتمالاً همین افزونه مشکل شماست.


امکانات

  • محافظ منبع دیجیتس
  • بریج LiteSpeed، WP Rocket، FlyingPress، W3TC، Hummingbird، Cache Enabler
  • کمک به WP Super Cache، WP Fastest Cache، SiteGround، Breeze از طریق محافظ منبع
  • استثناهای ایمنی برای لاگین، فرم دیجیتس، ووکامرس
  • مسیرهای استثنای سفارشی
  • پنل تنظیمات شیک با راهنما برای هر بخش
  • رابط انگلیسی + فارسی با پشتیبانی RTL
  • فیلتر برای توسعه‌دهندگان
  • بدون پچ کردن فایل‌های خود دیجیتس

نصب

  1. ریپو را ZIP بگیرید یا کلون کنید
  2. پوشه digits-cache-compat را در wp-content/plugins/ بگذارید
  3. افزونه را فعال کنید
  4. بروید به تنظیمات ← سازگاری کش دیجیتس
  5. پیش‌فرض‌ها (سازگاری + محافظ منبع) را روشن بگذارید
  6. یک‌بار کش صفحه را Purge کنید
  7. یک صفحه عمومی را به‌عنوان مهمان باز کنید و HIT/MISS کش را چک کنید

توضیح تنظیمات

۱) سازگاری اصلی

  • فعال‌سازی سازگاری: کلید اصلی روشن/خاموش
  • محافظ منبع دیجیتس: پیشنهادی؛ اصلاح ریشه‌ای برای همه کش‌ها

۲) بریج افزونه‌های کش

بریج همان کشی که واقعاً استفاده می‌کنید را روشن کنید.
بریج‌ها تعریف‌های دیرهنگام دیجیتس (مثل مودال فوتر) را هم پوشش می‌دهند.

۳) استثناهای ایمنی

صفحاتی که این افزونه اجباراً به کش برنمی‌گرداند:

  • صفحات فرم/حساب دیجیتس
  • سبد، تسویه، حساب ووکامرس
  • wp-login.php
  • مسیرهای سفارشی شما
  • همیشه: ?login= / ?logout= / ?lnounce=

۴) ابزارهای توسعه‌دهنده

  • نمایش تصمیم در ادمین‌بار
  • لاگ اختیاری در debug.log

پشتیبانی


لایسنس

GPL-2.0-or-later

About

Restores WordPress page caching when Digits breaks it with DONOTCACHEPAGE. | سازگاری کش دیجیتس

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages