Performance
Cloudflare cache rules and performance optimisation for HiAnime
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.
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:
| Setting | Value |
|---|---|
| Cache eligibility | Eligible for cache |
| Browser TTL | Respect origin TTL |
| Cache key | Include query string (unless noted) |
| Cache by device type | Off |
| Ignore query string | Off |
| Serve stale while revalidating | Optional — On |
| Request methods | GET only |
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/")| Setting | Value |
|---|---|
| Edge TTL | Override origin — 6 hours |
| Cache key | Default |
Rule 2 — Episode Servers
(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/episode/servers/")| Setting | Value |
|---|---|
| Edge TTL | Override origin — 6 hours |
| Cache key | Default |
Rule 3 — Anime Qtip
(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/anime/qtip/")| Setting | Value |
|---|---|
| Edge TTL | Override origin — 1 hour |
| Cache key | Default |
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/"
)| Setting | Value |
|---|---|
| Edge TTL | Override origin — 5 minutes |
| Cache key | Include query string |
| Required query params | date, 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/"
)| Setting | Value |
|---|---|
| Edge TTL | Override origin — 30 minutes |
| Cache key | Include query string |
| Required query param | tzOffset |
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/"
)| Setting | Value |
|---|---|
| Edge TTL | Override origin — 5 minutes |
| Cache key | Include query string |
| Required query param | keyword |
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/"
)| Setting | Value |
|---|---|
| Edge TTL | Override origin — 5 minutes |
| Cache key | Default |
Rule 8 — Comment Lists
(http.request.method eq "GET") and
starts_with(http.request.uri.path, "/wp-json/hianime/v1/comments/")| Setting | Value |
|---|---|
| Edge TTL | Override origin — 2 minutes |
| Cache key | Include query string |
How to Add a Cache Rule in Cloudflare
- Log in to the Cloudflare dashboard and select your site
- Go to Caching → Cache Rules
- Click Create rule
- Paste the expression from the relevant rule above into the Custom filter expression field
- Set Cache eligibility to
Eligible for cache - Set the Edge TTL as specified for that rule
- Set Browser TTL to
Respect origin TTL - Save and deploy the rule
- Repeat for each rule
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:
- Go to Cloudflare → Caching → Configuration
- Click Purge Everything (or use Custom Purge to target specific URLs)
Always purge both the theme cache (via OtakuThemes > Cache) and the Cloudflare cache after updating the theme to a new version.