• Resolved kechuvitalione

    (@kechuvitalione)


    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);
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter kechuvitalione

    (@kechuvitalione)

    Thank you very much, the last question: how can I add this to a code to use it with a shortcode?

    Plugin Support qtwrk

    (@qtwrk)

    if (defined('LSCWP_V')){
    do_action( 'litespeed_purge_url', '/something/somepage/' );
    }

    please try this

    what do you mean with a shortcode ? like purge cache by shortcode ?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Purge cache for url’ is closed to new replies.