How to Cache the Init Embed Posts Plugin’s REST API with Cloudflare Cache Rules

Are you using the Init Embed Posts plugin to share WordPress posts across other websites using clean, modern-looking embed cards—without iframes? To ensure fast loading, especially when the same post is embedded across multiple sites, you should enable Cloudflare Cache Rules to cache the plugin’s REST API.

How to Cache the Init Embed Posts Plugin’s REST API with Cloudflare Cache Rules

The plugin uses the following endpoint to serve embed data:

/wp-json/initempo/v1/post

Starting from the latest version, it also supports an additional endpoint:

/wp-json/initempo/v1/product

Why Cache the Init Embed Posts REST API?

  • Perfectly suitable: the content rarely changes => long-lasting cache with high efficiency
  • Resource-saving: reduces the number of WordPress queries
  • Faster embeds: external sites will display embed cards instantly
  • Optimized for CDN: allows Cloudflare to serve content directly from edge servers

Additionally, the plugin already supports wp_cache_set() on the backend, so you can confidently pair it with a CDN like Cloudflare without worrying about stale content.

Accessing Cache Rules in Cloudflare

  1. Log in to Cloudflare and select your domain
  2. Go to the Caching tab → Cache Rules
  3. Click Create Rule

Create a Cache Rule for Init Embed Posts

Give your rule a name, such as Cache Init Embed Post API, then click Edit expression and enter this condition:

(http.host contains "example.com" and starts_with(http.request.uri.path, "/wp-json/initempo/v1") and not http.cookie contains "wordpress_logged_in_")

Note: Replace example.com with your actual domain.

Set Cache Behavior

  • Cache status: On
  • Edge TTL: Choose 86400s (1 day), or longer if your content doesn’t change often
  • Cache key: Click Add setting, then select Cache Deception Armor to protect against spoofed query strings

Click Deploy to save your rule.

Auto-Purging Cache When Content Updates?

If you want the API to reflect content updates automatically, install the Cloudflare for WordPress plugin and enable:

  • Auto Purge Content On Update

This ensures the cached API content is purged whenever you update a post.

How to Verify If Cache Is Working

  1. Open a browser in Incognito mode
  2. Visit a site that embeds a post (or call the API directly)
  3. Open DevTools → go to the Network tab
  4. Find the request to /wp-json/initempo/v1/...
  5. Check the cf-cache-status response header. If it’s HIT, caching is active

Conclusion

The Init Embed Posts plugin helps you share WordPress post content beautifully, quickly, and automatically. Enabling REST API caching with Cloudflare significantly boosts performance—especially when the same post is embedded on multiple websites. This simple upgrade helps you deliver fast embeds, reduce server load, and create a smoother experience for your readers.

Comments


  • No comments yet.

Init Toolbox

Press Ctrl + \ on desktop, or swipe left anywhere on mobile.

Login