Reputation: 5
I got a problem about browser cache when I already add/edit record in database. The data in database changed but in view not change. I must press F5 in browser for refresh that page and it'll show updated data.
Please guide to me how to solve this problem, Thanks.
Sorry I forgot to told you guys, In my application has two part.
This's my relevant code in Front part.
In Controller
class ProductController extends Controller
{
public function actionIndex()
{
$products = Product::model()->getProductList(); // use findAll() method
$this->render('index', array('products' => $products));
}
}
In Model
class Product extents CActiveRecord
{
/*
*
* The other code that generated by Gii
*
*/
public function getProductList()
{
return $this->findAll();
}
}
In View
<html>
<body>
<ul class="thumbnails thumbnails-product">
<?php foreach ($products as $product): ?>
<li class="span3" style="margin-left:0px;">
<div class="thumbnail">
<img class="img-thumb" src="../images/<?php echo $product->PDT_IMG" />
<?php echo CHtml::link($product->PDT_NAME, array('product/view/' . $product->PDT_ID)); ?>
<span class="price"><?php echo $product->PDT_PRICE; ?></span>
</div>
</li>
<?php endforeach; ?>
</ul>
</body>
</html>
Upvotes: 0
Views: 443
Reputation: 5
The problem has been solved.
I just add
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
Everytime that view load, it'll reread page and doesn't keep any cache.
Upvotes: 0
Reputation: 1199
May be this can help you out: Real-time display of server push data using Server-Sent Events (SSE)
this is server push technique by which we can fetch data in every changes made automatically and also after a certain time.
Upvotes: 0
Reputation: 7530
If you want something to update on-the-fly, I think you're looking for in place editing
.
You could take a look at this extension which does that for you.
Especially this part.
Upvotes: 1