Performance

Cloudflare cache rules and performance optimisation for HiAnime

Updated April 30, 2026
OtakuThemes Team

Performance Tab

The Performance tab provides performance-related settings for HiAnime, including tools to fine-tune how your site handles caching and delivery at the server level.

Go to OtakuThemes > Performance to access these settings.


Cloudflare Cache Rules

If your site is behind Cloudflare, you should configure Cache Rules so that each REST API endpoint used by HiAnime is cached at the edge with the correct TTL. This dramatically reduces load on your origin server and speeds up the site for visitors worldwide.

Cloudflare Cache Rules vs Theme Cache

The theme's built-in cache (found in the Cache tab) clears WordPress-level transients. Cloudflare Cache Rules operate at the CDN edge — they are separate and complementary. You need to configure both.

Global Rule Settings

Apply these settings to all cache rules below:

SettingValue
Cache eligibilityEligible for cache
Browser TTLRespect origin TTL
Cache keyInclude query string (unless noted)
Cache by device typeOff
Ignore query stringOff
Serve stale while revalidatingOptional — On
Request methodsGET only
Never Cache POST Requests

Do not cache POST requests. Continue-watching, login, watchlist, ratings, comment submit, and user settings must always reach the origin server uncached.


Rule 1 — Episode List

(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/episode/list/")
SettingValue
Edge TTLOverride origin — 6 hours
Cache keyDefault

Rule 2 — Episode Servers

(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/episode/servers/")
SettingValue
Edge TTLOverride origin — 6 hours
Cache keyDefault

Rule 3 — Anime Qtip

(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/anime/qtip/")
SettingValue
Edge TTLOverride origin — 1 hour
Cache keyDefault

Rule 4 — Schedule Day

(http.request.method eq "GET") and
(
  http.request.uri.path eq "/wp-json/hianime/v1/schedule/day" or
  http.request.uri.path eq "/wp-json/hianime/v1/schedule/day/"
)
SettingValue
Edge TTLOverride origin — 5 minutes
Cache keyInclude query string
Required query paramsdate, tzOffset

Rule 5 — Schedule Widget

(http.request.method eq "GET") and
(
  http.request.uri.path eq "/wp-json/hianime/v1/schedule/widget" or
  http.request.uri.path eq "/wp-json/hianime/v1/schedule/widget/"
)
SettingValue
Edge TTLOverride origin — 30 minutes
Cache keyInclude query string
Required query paramtzOffset

Rule 6 — Search Suggestions

(http.request.method eq "GET") and
(
  http.request.uri.path eq "/wp-json/hianime/v1/search/suggestions" or
  http.request.uri.path eq "/wp-json/hianime/v1/search/suggestions/"
)
SettingValue
Edge TTLOverride origin — 5 minutes
Cache keyInclude query string
Required query paramkeyword

Rule 7 — Home Comments

(http.request.method eq "GET") and
(
  http.request.uri.path eq "/wp-json/hianime/v1/home-comments" or
  http.request.uri.path eq "/wp-json/hianime/v1/home-comments/"
)
SettingValue
Edge TTLOverride origin — 5 minutes
Cache keyDefault

Rule 8 — Comment Lists

(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/comments/")
SettingValue
Edge TTLOverride origin — 2 minutes
Cache keyInclude query string

How to Add a Cache Rule in Cloudflare

  1. Log in to the Cloudflare dashboard and select your site
  2. Go to Caching → Cache Rules
  3. Click Create rule
  4. Paste the expression from the relevant rule above into the Custom filter expression field
  5. Set Cache eligibility to Eligible for cache
  6. Set the Edge TTL as specified for that rule
  7. Set Browser TTL to Respect origin TTL
  8. Save and deploy the rule
  9. Repeat for each rule
Rule Order

Cloudflare evaluates cache rules top-to-bottom and stops at the first match. Place more specific rules (e.g. Schedule Day) above more general ones if there is any path overlap.


Purging the Cloudflare Cache

After making significant content changes — publishing new anime, editing episodes, or changing theme settings — purge the Cloudflare edge cache so visitors see fresh data immediately:

  1. Go to Cloudflare → Caching → Configuration
  2. Click Purge Everything (or use Custom Purge to target specific URLs)
Purge After Theme Updates

Always purge both the theme cache (via OtakuThemes > Cache) and the Cloudflare cache after updating the theme to a new version.