Purge cache button

catracalivre

New member
The "purge cache" button isn't very clear; it's impossible to tell if it's clearing the entire site cache or just the cache of the visited page.

It would also be very helpful to separate the options for clearing the entire cache and only the cache of a specific page, even defining which access groups can see this. Generally, editors and administrators could have this access.
 
The Purche Cache button in the admin UI is purging the entire cache for the site. Internally it does have the functionality to purge individual pages (that's how it works for automatic purging when things like a post is edited).

While I'm not opposed to letting people manually purge individual pages, there's also a balance between easy of use and functional complexity. An example of this is that when a post is edited, there's actually about 20 URLs that are purged... the main post page, the home page (in case it's being presented on the home page), atom, rss, rss2, rdf feed URLs, comment URLs, categories that post is contained in, etc. So giving people the ability to purge an individual page may cause confusion about why the post itself wasn't fully purged in all the underlying places.

Just so I have a better understanding of what you are doing exactly, what's your use case for wanting to purge a specific page from Cloudflare's cache?
 
Já tive algumas experiências ruins com outros plugins que não limpam corretamente o cache de tipos de postagem específicos ou, por exemplo, da página inicial de um site que foi construída com opções de página.
 
Já tive algumas experiências ruins com outros plugins que não limpam corretamente o cache de tipos de postagem específicos ou, por exemplo, da página inicial de um site que foi construída com opções de página.
As long as plugins are using normal WordPress functions/mechanisms to do edits, things should be purged properly. Any of these internal WordPress actions will trigger the purge logic for that post (and all the URLs that go along with it):
  • post_updated (an edit)
  • deleted_post
  • delete_attachment
  • transition_post_status (if a post changes to/from published)
...there's more triggers for purging as well. Things related to comments, switching/editing themes, etc.

If someone has additional custom triggers they want to make part of it, you can use the cloudflare_purge_url_actions filter as well (could be added by a plugin, theme or even manually via wp-config.php edit).

If there's a specific plugin that's doing something bizarre (like direct database edits via SQL), it wouldn't trigger the correct WordPress actions though. If you know of a plugin that is doing something that isn't triggering a purge cache when it should be, let me know... I could poke around on that plugin and see if there's something I can do on my end to make it work properly. For me, I'd rather fix the underlying issue than expect a user to need to manually purge individual URLs (less work and human error potential for users).
 
No caso de funções personalizadas, eu poderia usar 'cloudflare_purge_url_action'? Existe alguma documentação sobre esse hook?

Tenho algumas ações personalizadas; por exemplo, na página inicial do site há uma tarefa cron que extrai dados do WordPress. Seria possível chamar a limpeza do cache da página inicial ao final dessa ação?
 
No caso de funções personalizadas, eu poderia usar 'cloudflare_purge_url_action'? Existe alguma documentação sobre esse hook?

Tenho algumas ações personalizadas; por exemplo, na página inicial do site há uma tarefa cron que extrai dados do WordPress. Seria possível chamar a limpeza do cache da página inicial ao final dessa ação?
If you have the ability to call code (sounds like you probably do), you can leverage the same internal mechanism that the plugin uses to purge a list of URLs (for example when a post is edited).

PHP:
wp_schedule_single_event(time(), 'cfPurgeCache', ['https://yourhomepage.com']);

The 3rd parameter there is simply an array of URLs to be purged. The system passes the URLs to the WordPress cron system and schedules it to immediately happen. It's done that way to decouple the API call to do the purge from the user interface (things don't slow down for the user since it's done in the background).

If you want it to be right then and there (and you are okay with slightly slowing down the user interface to make the underlying API call), you could effectively call the cron job directly like so:

PHP:
\DigitalPoint\Cloudflare\Cron\Jobs::purgeCache($urls)

...again, $urls being an array of URLs.
 
Back
Top