【问题标题】:Controller in Kohana 3 does not appear to work, but has in the backgroundKohana 3 中的控制器似乎不起作用,但在后台运行
【发布时间】:2011-07-21 03:53:40
【问题描述】:

我的客户发现当他们点击删除时没有任何反应,但如果他们再次删除,他们会收到“id”不再存在的错误。

我觉得这很难相信,因为它实际上是离开页面然后被重定向回帖子。

视图中的链接:

<h4>Current Logo Image <span class='del'>
 (<?= HTML::anchor("playlist/imgdelete/$playlist->id/$logo->type", 'delete'); ?>)
</span></h4>

控制器进程:

public function action_imgdelete($id, $type)
{
    DB::delete('images')->where('playlist_id', '=', $id)
                        ->where('type', '=', $type)->execute();
    Message::success('Image deleted');
    Request::current()->redirect("playlist/edit/$id");
}

有谁知道这怎么可能?

【问题讨论】:

  • 页面上是否有 JavaScript 来捕获初始操作?
  • 不,这就是我如此惊讶的原因。因为我会明白的。
  • 页面是否被大量缓存?以前见过,但这是目前的理论
  • 我认为是的,但我还没有定义任何缓存系统。 Kohana 的默认缓存设置是什么?我目前正在使用 playlist/edit/$id?$time where $time=time() .. 这目前有效,但不太理想。还有什么想法吗??

标签: kohana kohana-3


【解决方案1】:

这可能是由于 Kohana 和您选择的浏览器之间存在双重阻塞缓存。

删除动作会发生,但由于攻击性,页面的缓存不会显示任何变化。再次击中将无效,因为您已经执行了该操作,但您的端没有任何视觉记录。

您可以通过在模板中添加 no-cache 标头标签来解决此问题:

<meta http-equiv="cache-control" content="no-cache" />

Kohana 设置的默认缓存寿命是一分钟:

/**
 * @var  integer  Default lifetime for caching, in seconds, 
 *                 used by [Kohana::cache]. Set by [Kohana::init]
 */
public static $cache_life = 60;

您可以从 system/classes/kohana/core.php

对其进行调整

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-19
    • 2019-03-28
    • 2011-10-02
    • 2014-04-22
    • 2011-09-03
    • 2019-01-16
    • 2016-10-20
    相关资源
    最近更新 更多