Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello @rockfire

    Yep it’s a known issue for me. First hit in the new day always returns the old information (because of MU plugin and setting combo) but next hits are okay which is better than waiting cache to timeout.

    I’ve tried with creating a custom MU plugin and it works better but this will cause many more issues ??

    In fact – I won’t update the plugin on my side or if there is something I want I will perform a manual merge but I think that plugin customers have to gain the ability to add/remove something from cache keys. Because every developer knows better how his caching must work depending of other logic.

    Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello @rockfire

    Think about this: We have a public accessed API and there is no way to control how customer calls any endpoint in it. They can add parameters in random ordering and that’s fine for me, for the plugin and for cloudflare.

    When there is an update to post related with the cache the plugin properly invalidates the cache and that’s fine too but I have to invalidate the cache on Cloudflare too. To prevent calling “purge all” I have to clear the cache by URLs but URLs are different – by their query params ordering and with/out “/” at the end and Cloudflare treats them as completely different because they are.

    How different they are (I love to compare everything with hashes):

    
    - https://example.com/wp-json/wp/v2/endpoint?original=1&a=2 - 91e82a98319b29979c19dae86129a0f9cdc51ef7
    - https://example.com/wp-json/wp/v2/endpoint/?original=1&a=2 - 642946ef5797e6d239fa5e595e6d13c6b6a66d06
    - https://example.com/wp-json/wp/v2/endpoint?a=2&original=1 - 015bb748f63d78d9f73d7bd25e3ff84f996f0798
    - https://example.com/wp-json/wp/v2/endpoint/?a=2&original=1 - 21548134109a41ebdca3b2f238c9e1ba9d4c7846
    

    I understand why the plugin makes all of these manipulations – to decrease amount of cached keys and to combine same resources no matter of used URL. This will cause higher cache hit rate. On the other hand I have to call CF to purge caches for these resources but the plugin recorded only the manipulated URL so I know for only one URL but people can access the same resource on different URLs ?? That’s all ??

    For me the issue is not in the Plugin but plugin can help with the solving of it.

    Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello @rockfire

    This won’t help because the method you gave me makes a little manipulation of the url as build_request_uri() method in class Endpoint_Api do. I don’t know what is your knowledge about Cloudflare CDN (used in my project) but in their lower plans (except Enterprise) these URLs are completely different for them:

    
    - https://example.com/wp-json/wp/v2/endpoint?original=1&a=2
    - https://example.com/wp-json/wp/v2/endpoint/?original=1&a=2
    - https://example.com/wp-json/wp/v2/endpoint?a=2&original=1
    - https://example.com/wp-json/wp/v2/endpoint/?a=2&original=1
    

    But for the plugin these URLs will generate the same key as I said. Because of few points:
    $request_path = rtrim( $uri_parts['path'], '/' ); ~ line 229 – will remove right “/”
    ksort( $params ); ~ line 233 – this will sort params in the query string.

    If you check build_request_uri method the plugin doing the same. Also if you don’t want to add this change then please add it to the documentation because this behavior was unexpected for me ??

    Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello @rockfire

    The issue with daily invalidation and setting different cache timeout is because I’ve made few custom endpoints (I’m using wordpress as headless cms) to get the daily information by server time.

    For example:
    https://example.com/wp-json/wp/v2/delivery-days?day=current – which is returning current delivery day by date. Every cached url is set to cache from the first hit. If you hit this endpoint at 05:02 AM on 01-Sep-2020 the cache will expire on 05:02 AM on 02-Sep-2020 but for me the information is not valid. As you can understand there is more than 5 hours gap between cache and actual information.

    About sha1 vs md5 this may help. Also I have a bad experience with md5 collision while processing a big amount of data and hash it with md5.

    I’ve tried the plugin and how it works few days before I create this topic.

    Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello,

    As I said in my first topic Add Cache key generation hook – I’ve already made the changes if you wish to add it in your plugin the pleasure will be mine!

    Once again – Thank you for your amazing work because this plugin saved me a lot of time.

    Best regards,
    Georgi!

    Thread Starter Georgi Tsvetanov

    (@gtsvetanov)

    Hello,

    I’ve made a second topic called Save accessed URLs for a cache key where I’ve asked for additional functionalities but I’ve already made them for me. If you wish you can use add it to your code and release them as new version of the plugin. Because my git repository is private you can find my changes here as a patch – https://pastebin.com/SBi76fQs

    Once again – Thank you for your amazing work because this plugin saved me a lot of time.

    Best regards,
    Georgi!

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