問題描述
所以我在我的 Cakephp 應(yīng)用程序中打開了緩存閘門,現(xiàn)在我想關(guān)閉它們......
So I opened the cache floodgates in my Cakephp app and now I want to close them...
我已經(jīng)做了我能做的幾乎所有事情:刪除 tmp 文件夾中的所有文件(但不是文件夾),在我的應(yīng)用程序的 core.php 文件中打開Cache.disable",嘗試清除緩存在一些帶有 clearCache() 和 Cache::clear() 的控制器中(但我懷疑這不起作用,因?yàn)樗鼪]有加載控制器——由于緩存).
I've done pretty much everything I can: delete all files in the tmp folder (but not the folders), turned 'Cache.disable' on in the core.php file in my app, have tried clearing the cache from within some controllers with clearCache() and Cache::clear() (but I suspect this doesn't work because it's not loading the controller -- due to caching).
我?guī)缀跤行У赝V沽宋业拈_發(fā)過程,因?yàn)榫彺娌粫?huì)關(guān)閉.任何人都有一些我可以嘗試的想法?我開始認(rèn)為它可能在瀏覽器中,也可能在我的托管服務(wù)中,但可能只是 Cakephp 惹惱了我.
I've pretty much effectively halted my development process just because caching won't turn off. Anyone have some ideas that I could try? I'm starting to think it may be within the browser or maybe my hosting service, but it's probably just Cakephp messing with me.
推薦答案
要排除瀏覽器緩存作為根本原因,您可以嘗試添加以下幾行:
To rule out browser caching as the root cause, you might try adding the following lines:
header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0', false); // HTTP/1.1
header('Pragma: public');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Expires: 0', false);
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: no-cache');
根據(jù)我的經(jīng)驗(yàn),所有這些緩存破壞 HTTP 標(biāo)頭的組合適用于所有瀏覽器,并且還繞過了一些非常激進(jìn)的緩存代理.
The combination of all these cache-busting HTTP headers has, in my experience, worked in all browsers, and has got around some very aggressive caching proxies as well.
這篇關(guān)于如何在 Cakephp 中完全禁用緩存?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!