问题
My client is finding that when they hit delete nothing happens, but if they it it again they get the error that that 'id' doesn't exist anymore.
I find that hard to believe because it's actually leaving the page and then being redirected back to the post.
The link in the view:
<h4>Current Logo Image <span class='del'>
(<?= HTML::anchor("playlist/imgdelete/$playlist->id/$logo->type", 'delete'); ?>)
</span></h4>
The controller process:
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");
}
Does anyone know how this can be possible?
回答1:
This could be due to a double chokehold cache between Kohana and your browser of choice.
The delete action will have occurred, but because of the aggressiveness, the cache of the page will not show any change. Hitting again will be invalid since you've already performed the action, but nothing has visually registered on your end.
You can get around this by putting in the no-cache header tag in your template:
<meta http-equiv="cache-control" content="no-cache" />
The default cache life set by Kohana is a minute:
/**
* @var integer Default lifetime for caching, in seconds,
* used by [Kohana::cache]. Set by [Kohana::init]
*/
public static $cache_life = 60;
You can tweak it from system/classes/kohana/core.php
来源:https://stackoverflow.com/questions/6771088/controller-in-kohana-3-does-not-appear-to-work-but-has-in-the-background