Purge cache for url
-
Hello, how are you all? I need to know if there is a possibility that with a code when pressing a button and confirming an operation the cache of a specific url can be purged, this is what I have but it doesn’t work. I was able to make it do the general purge but not the purge of a specific page:
// Después de confirmar la venta con éxito
add_action(‘wp_ajax_agregar_venta’, ‘agregar_venta’);
add_action(‘wp_ajax_nopriv_agregar_venta’, ‘agregar_venta’);
function agregar_venta() {
// Tu código para agregar la venta…// Purgar la caché solo para la URL específica purgar_cache_para_url('https:ejemplo'); wp_die(); // Detiene la ejecución del script
}
function purgar_cache_para_url($url) {
// Comprueba si el plugin de caché está activo
if (function_exists(‘lscache’)) {
// Purga la caché solo para la URL específica
lscache()->purgeUrl($url);
}
}
- The topic ‘Purge cache for url’ is closed to new replies.