![](/img/trans.png)
[英]What is the purpose of $this->request->get['token'] in opencart customer login file?
[英]Opencart 3.x Cache-Control with $this->request->get
使用 Opencart 3.0.3.2 我開發了一個模塊,它在 Opencart 的管理部分顯示產品列表。 每個產品旁邊都有一個按鈕 - 按鈕動作如下:
https://example.com/admin/index.php?route=extension/shipping/mymodule&user_token=W0nBWaeKPjpeHFSMb4QmCqmt3sW7hA6Z&product_id=422&active_tab=1&addfree
通過檢查 $this->request->get['addfree'] 在 controller 中獲取 addfree。
問題在於緩存:
我在 2.3.0.2 安裝和 3.0.3.2 安裝中安裝了相同的模塊。 兩者都有幾乎相同的 .htaccess 文件。
3.x 堅持使用Cache-Control: max-age=900
從磁盤緩存加載我上面的 URL,如 .htaccess 中所指定
ExpiresByType text/html "access plus 15 minutes"
2.3.0.2 使用Cache-Control: no-store, no-cache, must-revalidate
我不知道為什么會這樣。 任何幫助表示贊賞。
解決方案: 正如 ADD Creative 在這篇文章中所述。
如果您想保持 .htaccess 保持原樣,並為文本/html 內容設置緩存時間跨度,但還要禁用 OC 3.x 響應和重定向的緩存,您可以按照上面鏈接帖子中的說明進行操作。
對於我自己,作為 OC 擴展的開發人員,我決定在這篇文章中使用選項 #3 來 go。
因此,在為 OC 3.x 開發我的擴展時,我必須記住:
$this->response->addHeader('Cache-Control: no-cache, no-store, must-revalidate'); $this->response->addHeader('Pragma: no-cache');
header("Cache-Control: no-cache, no-store, must-revalidate"); header("Pragma: no-cache");
通過這種方式,我絕對可以肯定,任何使用我的擴展程序的人都不會看到任何緩存,無論他們在 .htaccess 中有什么,我不會在這件事上遇到任何支持問題,我也不必要求他們更改任何內容命令我的擴展在他們的系統上工作。
而已!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.