PHOENIX-MEDIA / Magento-PageCache-powered-by-Varnish

Community version which is available on Magento Connect (http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html)
89 stars 49 forks source link

purge url programmatically #53

Open ClaudiuCreanga opened 8 years ago

ClaudiuCreanga commented 8 years ago

Is there a way to purge the url programatically?

I'm updating the stock by writing to the database directly and would like to purge product urls (or by product id) afterwards (not on product save).

Or, if not, how would you go about purging all varnish programatically? (Mage::app()->cleanCache()) doesn't work.

Thanks!

ClaudiuCreanga commented 8 years ago

So this would work for individual links: Mage::getModel('varnishcache/control') ->clean($host, sprintf('^%s$', $uri));

Emulator000 commented 8 years ago

You can purge URL programmatically with this simple code snippet: $cache = Mage::getSingleton('varnishcache/control'); if ($cache) { $cache->clean($_SERVER['HTTP_HOST'], 'URL/HERE'); }