• Resolved henmaker

    (@henmaker)


    As i need to speed up the query of the API, is that possible that all posts cache are automatically generate via a command/function that run by a cron job?

    For example, i run a cron job to call a function every week to generate all the posts cache. How to do this?

Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @henmaker

    Do you mean to regenerate all expired/flushed caches? Or do you mean to create caches that weren’t cached before? If you mean the last one, than that is almost impossible since there are so many different ways of calling the REST API. For instance you can get a list of pages by calling any of these:

    • /wp-json/wp/v2/pages
    • /wp-json/wp/v2/pages?orderby=date
    • /wp-json/wp/v2/pages?orderby=modified
    • /wp-json/wp/v2/pages?orderby=modified&order=desc
    • /wp-json/wp/v2/pages?orderby=modified&order=asc
    • /wp-json/wp/v2/pages?page=2
    • /wp-json/wp/v2/pages?page=2&per_page=100
    • /wp-json/wp/v2/pages?page=2&per_page=100&orderby=modified&order=asc

    Each of them resulting in a different cache record. Eventhough it is possible to generate all different combination of parameters, this isn’t something that would be very useful. It is only useful to cache something that is actually being called. So in stead of our plugin trying to guess what should be cached, it would be better if you would create a script that actually calls the REST API like the calls you want cached.

Viewing 1 replies (of 1 total)
  • The topic ‘Possible to generate all post cache automatically via a command’ is closed to new replies.