• Hi!

    I’m testing your plugin to control page caching based on the value of a specific cookie. I think I’ve found a bug and would like to submit a few suggestions.

    The bug is as follows. When a cookie exclusion rule contains any of the special characters used to define a regular expression ( . \ + * ? [ ^ ] $ ( ) { } = ! < > | : – #) or the % character, the RewriteCond test generated in the .htaccess file is treated as a regular expression and this expression is sometimes syntactically incorrect, which causes Apache to crash. All these characters should in fact be escaped, as it is done in the corresponding PHP test for the same rule.

    My suggestions are as follows. When testing cookie values to create an exclusion rule, currently we can only check whether the received cookies contain a certain string of characters. This is sometimes insufficient. It would be useful to also be able to define an exclusion:

    • if the received cookies do not contain a certain string of characters,
    • and, even better, if the received cookies match or do not match a specific regex.

    For now, in my tests, I’m setting 5 exclusion rules for cookies, even though a single rule would suffice if I could use a regular expression. To work around the bug, I have to patch the generated .htaccess file to fix incorrect RewriteCond’s. And since caching is in my case based on cookie values, I don’t use the preload because exclusion rules based on cookie values do not seem to be checked by it (Right ?).

    With all that done, the WP Fastest Cache plugin works great!

    Thank you in advance for taking this message into consideration!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Emre Vona

    (@emrevona)

    I will check and let you know.

    Plugin Author Emre Vona

    (@emrevona)

    First of all, thank you very much for helping me improve the product.

    1. Thanks to you, I realized that the Regex rules were not being added to the .htaccess file. I fixed the problem.

    2. You cannot write regex rule for the cookie exclusion because we do not have such a feature. But even if you write regex, there shouldn’t be any problems. This was a mistake. And I fixed that mistake.

    Can you delete wp fastest cache and download the following version to get the latest changes please?

    https://downloads.wp.xz.cn/plugin/wp-fastest-cache.zip

    • This reply was modified 1 month, 3 weeks ago by Emre Vona.
    • This reply was modified 1 month, 3 weeks ago by Emre Vona.
    Thread Starter erpiu

    (@erpiu)

    Hi Emre,

    Thanks a lot for your quick feedback.

    The version you sent to me works as expected : cookie exclusion rules are now correctly written in the .htaccess file with special characters used to define a regex being escaped (% didn’t need to be escaped. You are right).

    I assume that your fix will be integrated in the next release of the plugin.

    Regarding my suggestions, I do understand that it is not possible today to use regexes in cookie exclusion rules but this features would be very useful for applications where caching is based on certain values of a given cookie or on the presence or the absence of a cookie. We could imagine something similar to what is used in the RewriteCond’s in .htaccess files : regexes with possibly a special character (!) at the front that would reverse the condition.
    As an example, which exclusion rule can we today define to allow caching only if the cookie “enable_cache” is set ? I’m afraid, we can’t. With regexes the exclusion rule would be simply something like ” !enable_cache=”.

    May be in a future release ?

    Thanks again !

    Plugin Author Emre Vona

    (@emrevona)

    you are welcome. the changes will be available in the next version.

    I will try to add your feature request and let you know.

    Thread Starter erpiu

    (@erpiu)

    Great ! Whenever you need a beta tester, feel free to reach out to me !

    Thread Starter erpiu

    (@erpiu)

    Hi Emre,

    After digging into the plugin’s source code, I think I’ve found a way to implement the features I mentioned in my previous messages (the ability to accept regular expressions in cookie exclusion rules, as well as the ability to invert the condition in these rules—“contain” or “regex”—by prefixing them with the “!” character).

    I’ve done it; there are few changes to make, and it works very well, at least in a simple configuration of the plugin. It is indeed possible—and even likely—that additional modifications will be necessary to account for the many configuration options in WP Fastest Cache. If you’re interested, how can I send you this updated version for your review?

    Through the contact section of your website or directly via this support forum?

    Regards,

    Erpiu

    Plugin Author Emre Vona

    (@emrevona)

    hi again @erpiu , I added your feature request. you can delete wp fastest cache and download the following version to get the latest changes.

    https://downloads.wp.xz.cn/plugin/wp-fastest-cache.zip

    Thread Starter erpiu

    (@erpiu)

    Hi @emrevona,

    In the version you sent me, you support regexes in cookie exclusion rules. Great!

    But it is apparently not possible to invert the condition specified in the rule, for example by prefixing the condition with the ! character. I admit that this way of expressing an inverted condition isn’t very user-friendly, but it has the major advantage of allowing new features to be introduced without affecting existing configurations set by current users of the plugin.

    Personally, I need this capability because I must allow caching only for pages accompanied by a cookie whose value matches a specific regular expression. This would result in an exclusion rule of the following form: !my_cookie=value1,value2(,value3)?(;|$)

    The inversion of the condition using the ! prefix could be introduced for cookie exclusion rules (with or without regexes), but also, for consistency’s sake, for fast(?) all other types of exclusion rules where the user specifies a condition.

    Adding such a feature in both the files wpFastestCache.php and inc/cache.php shouldn’t be very difficult, unless this addition affects other parts of the plugin that I’m not familiar with…

    What do you think?

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.