更新:
问题:
Flash 消息未显示。
当我在应用程序中使用事件/停用/添加/编辑功能时,应该会显示 Flash 消息,但不会显示。
当我清除浏览器缓存时,它第一次工作正常(显示 Flash 消息)。 但现在我再次使用“事件/停用/添加/编辑”时,闪存消息未显示。 再次,当我清除浏览器缓存时,它工作正常。
我发现了缓存问题。 但我怎样才能摆脱这个缓存问题。
上一个问题:
我已经找到了缓存问题。
我有一个严重的问题。 CakePHP Flash 消息在一台 PC 上的 Chrome、Fire Fox 浏览器中不显示,但在另一台 PC 上的 Chrome、Fire Fox 浏览器中显示相同的 Flash 消息,而且 JavaScript 在这两种浏览器上都无法显示。
可能出现什么问题?
我在其他 20 台 PC 上检查过,Flash 消息在两个浏览器中都工作正常。
最佳答案
我想你使用缓存助手。
他是这么说的 CakePHP documentation :
Marking Non-Cached Content in Views
There will be times when you don’t want an entire view cached. For example, certain parts of the page may look different whether a user is currently logged in or browsing your site as a guest.
To indicate blocks of content that are not to be cached, wrap them in
<!--nocache--> <!--/nocache-->
像这样:
<!--nocache-->
<?php if ($this->Session->check('User.name')): ?>
Welcome, <?php echo h($this->Session->read('User.name')); ?>.
<?php else: ?>
<?php echo $this->Html->link('Login', 'users/login'); ?>
<?php endif; ?>
<!--/nocache-->
就您而言:
<!--nocache-->
$this->Session->setFlash('My text here');
<!--/nocache-->
关于php - 由于缓存,CakePHP Flash 消息未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26708399/