Caching everything
-
Hello,
Everything I tried end up caching either URLs with a trailing slash (and not the ones without a trailing slash) or without a trailing slash (and not the ones with a trailing slash).
Is there a way to cache everything with AND without the trailing slash ?
I want to cache directory pages with trailing slash and file pages without extension but without trailing slash.
Thank you
-
By default Cache Enabler will not support delivering a cached page with AND without a trailing slash. It will only do with OR without a trailing slash. You can optionally override this with custom behavior by using the
cache_enabler_bypass_cachehook.In case you’re curious, this method is what controls the trailing slash behavior right now.
Thank you for your reply which gives true clues on where to look, unfornately I didn’t manage to bypass the cache.
Do I have to remove the setting lines in settings file :
'use_trailing_slashes' 'permalink_structure'or to set it up in some ways ?
Is it okay to place the filters in functions.php setting it to false ?I just tried using that hook in the way I previously thought and it turns out it won’t work for this scenario. I apologize for that oversight.
This may be able to be customized in a future change to our exclusion system, but if you’d like this behavior now you’ll have to make a small change to the plugin itself. You’ll need the prerequisite knowledge to make this change. Furthermore, please keep in mind this change will be gone upon updating Cache Enabler, so it’d have to done again. All that would need to be removed is the
|| self::is_wrong_permalink_structure()characters from line 269 in thecache-enabler/inc/cache_enabler_engine.class.phpfile.Absolutely no problem with this, you are helping.
is_wrong_permalink_structurewas the last occurence of string I searched yesterday across all files of the plugin but I would have not imagine deleting this part.Thank you very much, it works perfectly.
If this scenario (mixing both URLs) has not been implemented before, can I ask you if there is a deep reason from an SEO point of view or something else for having to choose to use either the trailing slash or not on URLs of a whole site ?
Can it be wrong to mix it ?Following your answer to these questions, yes it would be a great to have a setting for using with or without or mixed trailing slash.
Fantastic! I’m happy to hear that. The way Cache Enabler handles trailing slashes comes from how WordPress handles it. If WordPress would normally redirect a request to append/remove a trailing slash then Cache Enabler is setup to honor that.
Due to when the page cache is delivered, which is when the
advanced-cache.phpdrop-in is included, is why we can’t check what WordPress is actually going to do. That is why we base it off of the request URI. Maybe there is a better way to handle this, but that is what we have for now. I’m not sure what is best practice, but I always use one or the other. I never use both with and without trailing slashes on a site.A lot more control, including what you want, hopefully will be made possible with a new system I’d like to add. Unfortunately that will be quite some time before it can be created and released as other things have to be built beforehand in order for it to work. Until then I’m glad you have a solution for your use case. π
OK thank you for explaining this.
In fact, I changed the default behvior thanks to custom permalinks in order to respect this logic :https://home.com/
|___directory1/
|___index.php –> (1) url : https://home.com/directory1/
|___page-name1.php–> (2) url : https://home.com/directory1/page-name1(1) Index of the directory never displayed so the url ends up with a trailing slash
(2) Page of the directory but not a subdirectory. As extensions of files are not displayed, it ends up with a url without extentions and without trailing slash.
But I understand the weak point of this way to work is that no automatic redirect can be set up either to add or remove the trailing slash following the settings. Only the canonical tag indicates the correct url but this seems to be not handled by WP for categories and tags pages in order to avoid duplicates (a behavior that I don’t understand). Maybe here is why it is one or the other.
Thanks again Corey
The topic ‘Caching everything’ is closed to new replies.