Optimize WordPress for REST API

I am interested in tips for optimizing WordPress’s response times for the REST API and Frontity in general. This is because when pulling some pages of my testing environment through Google PageSpeed, I’m receiving messages about ā€˜Reduce initial server response time’.

I’m not sure if this problem stems from Vercel or from my WordPress installation, but it looks like installing a caching plugin for Rest responses (WP REST Cache) makes some difference.

When using Frontity, you don’t need a whole lot of functionality that WordPress loads by default. I’m reading that WordPress loads plugins and themes even when doing a request to the REST API. So maybe some parts shouldn’t load? But of course you want to keep the ability to use the back-end for managing content, and the reponse of the REST API shouldn’t be altered by taking theme and plugins out of use… I found this plugin (Plugin Load Filter) which provides an interface for disabling any of your plugins for (among others) the REST API.

I’ve also read about shortinit and tried to implement that in my testing environment. But I can’t really find a good to way to implement it.

How did Frontity itself optimize loading times on the WordPress side?

What we’re doing in our web right now is not only caching the REST API response but also the HTML. We’re using Pantheon and we’re using their plugin Pantheon Advanced Page Cache for this, and it’s working really well. This way, the cache works as any other WordPress site.

We’re not filtering the Rest API, but I’m aware that other users have done that to improve REST API response times. But I would say that the best way to improve the performance is to have a good cache system for both the API and the HTML, so if the content doesn’t change, it can be served from a CDN and you don’t have to run everything again.

You can take a look at this post where Luis explains in a more detailed way how cache could work with Frontity, I think it’s pretty interesting -> Moving an Existing WordPress website with over 5000 Articles

I think the first thing to document here is the importance of cache in a Frontity project and how to use in different levels (WP, Frontend, …)

There are some issues already created for this. I have added this comment ini this issue to take this thread into account

2 Likes