CodeIgniter Forums
Caching only pages without query string - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Caching only pages without query string (/showthread.php?tid=78482)



Caching only pages without query string - henry_miaomiao - 01-27-2021

Is there a way to save the cache only for pages without querystring in the url?

Example:

www.site.com/product (cache yes)

www.site.com/product?cat=4&dr=45 (cache no)

Thanks


RE: Caching only pages without query string - iRedds - 01-27-2021

(01-27-2021, 04:22 AM)henry_miaomiao Wrote: Is there a way to save the cache only for pages without querystring in the url?

Example: 

www.site.com/product (cache yes)

www.site.com/product?cat=4&dr=45 (cache no)


PHP Code:
// app/Config/Cache

public $cacheQueryString true;


// in the controller

if (! $this->request->getGet('cat') && ! $this->request->getGet('dr')) {
    $this->cachePage(100); 


Maybe there is an easier solution.


RE: Caching only pages without query string - henry_miaomiao - 01-27-2021

(01-27-2021, 08:27 AM)iRedds Wrote:
(01-27-2021, 04:22 AM)henry_miaomiao Wrote: Is there a way to save the cache only for pages without querystring in the url?

Example: 

www.site.com/product (cache yes)

www.site.com/product?cat=4&dr=45 (cache no)


PHP Code:
// app/Config/Cache

public $cacheQueryString true;


// in the controller

if (! $this->request->getGet('cat') && ! $this->request->getGet('dr')) {
    $this->cachePage(100); 


Maybe there is an easier solution.

Thanks; could be usefull