Plugin Contributor
Nauris
(@pyronaur)
Hi @dickraney!
I’d suggest you re-think the approach here slightly. Caching is great to have wherever possible, which is the assumption caching plugins are built with. So you want every page on your site to be as fast as possible.
With that in mind – if certain areas in your site are dynamic and need to be excluded from the cache, you can exclude them using the “Rejected URL Strings” field.
I’m not sure what your IDX feed page structure is like, but let’s say it looks something like this:
https://site.com/idx/product1
https://site.com/idx/product1
https://site.com/idx/product1
You can use the “Rejected URL Strings” to reject the URL like so:
/idx/*
That’s going to exclude all URLs that match /idx/ from the cache.
Does that solve the issue?
Yes, I understand that, but in my case it would just be much simpler to exclude everything and then make exceptions for the ones that I want to allow. Unfortunately, it’s not as simple as the example you gave with all links proceeded with idx.
Plugin Contributor
Nauris
(@pyronaur)
What do the links look like? Maybe there’s another pattern you could specify.
Alternatively, you can set a DONOTCACHEPAGE constant to true on the pages you want to be skipped from the cache, so if you really want to only cache the home page, you can do it like this:
if( !is_home() && !is_front_page() && ! defined('DONOTCACHEPAGE') ) {
define('DONOTCACHEPAGE', true);
}
That snippet will help. If I do that, how do I designate a page (other than home page) that I do want to cache?
It looks like that snippet force DONOTCACHE (not cached) on everything except homepage/front_page that isn’t specifically defined as DONOTCACHEPAGE. So, a page /EXAMPLE would not be cached unless I define it as DONOTCACHEPAGE. In other words. defining as DONOTCACHEPAGE actually makes it get cached. Or am I misunderstanding the PHP logic ! defined('DONOTCACHEPAGE')?
Plugin Contributor
Nauris
(@pyronaur)
In PHP, you can only define constants once, so this additional check makes sure you don’t get warnings if for some reason the DONOTCACHEPAGE constant is already defined.