dtwd74916 2014-12-19 12:01
浏览 41

在Magento中检测Varnish活动的URL检测

I'm using Magento in conjunction with Varnish Cache and I'm developing a module.

Here's my plan: detect URL at the controller_action_predispatch event and if the URL matches what I'm looking for, run a method.

Pretty simple, and this works:

$this->_action = $observer->getEvent()->getControllerAction();
$request = $this->_action->getRequest();
if ($request->getRequestString() == 'my route') {
    //Process Action
}

Say for example, I look for /checkout/cart/ as an example, then this works fine... locally.

On our staging server, we have Varnish Cache running via the Nexcess Turpentine extension. So, /checkout/cart/ looks like this instead:

/turpentine/esi/getBlock/method/esi/access/private/ttl/86400/hmac/7b123a94c32437dbc3e871e9a8671e0c25acfd8b0d9aac4ef67e1a1e0ffe75b0/data/FG4tbo.vXe1BP-stDckM6MmxY8YJuimtBsPXs4DN60EvEjeTv6qGAV8dLiEF6AySMcp8zBoGCxrPo-3i6h1IeueERsjAyw8sRQcvh-5nmMr8wqUlNR36YRv6tgHn9tDsRBwjm6AurTfx46dLgi6HFhJcUwpPkl957MQhMBsN5tfwLWnYS7U0SfNxYKvHaXXyHQcvGVNEpfUKUMPsICC7wzJ7iGaahd8akvZ1VpZ.ifLOfWaXDlqdybZaQj2ZPq85DzBrM2-6sVbdv1fL4OOZxC-0A5iizQcwg9leLR1.n67bKCHYpndbfVxUpTN1Dxystq463pzP5tlm-sy6Sg6GH743ZQw6BMG8wlbgnPfWDu5Gf1Ty1K3Ercz54eOB59r7OCIUzEYE9HFQreMzIUaTEMg9GHBakggdyyi4WuHSB6E=/

I've also tried checking the $_SERVER['REQUEST_URI']; which yields the same result and Mage::helper('core/helper')->getCurrentUrl(); which is the same again.

I need to find out what route the Varnish Output resolves to, otherwise I cannot judge what page the user is currently visiting.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用