Cache-Control with $this->request->get
Posted: Sat Nov 02, 2019 9:36 am
Using Opencart 3.0.3.2
I have developed a module for 2.3.0.2 & now converting it to 3.x. The module displays a list of products in the admin section of Opencart.
Each product has a button next to it which is meant as a toggle (enable/disable free shipping) to add/del free shipping to each product.
The button action is as follows:
addfree is picked up in the controller by checking $this->request->get['addfree']
Some action is taken by the controller (database entry etc) and when the page is returned, the button action is changed to:
So it toggles between add/del free shipping.
The problem is with caching:
In chrome when I click this toggle button, I can see that the response headers are:
Even if I disable caching from Dashboard Developer Settings, I still get the same as above.
My aim here is NOT to disable caching temporarily.
My goal is to disable caching completely whenever my module's URL is requested by the administrator who installed my module.
The only way I can get it to work as intended is by adding the following to my .htaccess file:
The problem with using the above is obvious.
I only want to set these headers when it comes to my module.
I do not mind if my whole module has NO CACHING.
How do I achieve this with Opencart 3.x?
I have developed a module for 2.3.0.2 & now converting it to 3.x. The module displays a list of products in the admin section of Opencart.
Each product has a button next to it which is meant as a toggle (enable/disable free shipping) to add/del free shipping to each product.
The button action is as follows:
Code: Select all
https://example.com/admin/index.php?route=extension/shipping/mymodule&user_token=W0nBWaeKPjpeHFSMb4QmCqmt3sW7hA6Z&product_id=422&active_tab=1&addfree
Some action is taken by the controller (database entry etc) and when the page is returned, the button action is changed to:
Code: Select all
https://example.com/admin/index.php?route=extension/shipping/mymodule&user_token=W0nBWaeKPjpeHFSMb4QmCqmt3sW7hA6Z&product_id=422&active_tab=1&delfree
The problem is with caching:
In chrome when I click this toggle button, I can see that the response headers are:
Code: Select all
Cache-Control: max-age=900
My aim here is NOT to disable caching temporarily.
My goal is to disable caching completely whenever my module's URL is requested by the administrator who installed my module.
The only way I can get it to work as intended is by adding the following to my .htaccess file:
Code: Select all
<ifModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</ifModule>
I only want to set these headers when it comes to my module.
I do not mind if my whole module has NO CACHING.
How do I achieve this with Opencart 3.x?