Cache key performance impact

From a performance perspective which would be preferred if we want to set custom cache keys.

  1. Setting Custom Cache Key in page rules. OR
  2. Creating cache key in Worker.
    And in general, wanted to know if Cloudflare recommends having Page rules or Worker implemented for handling caching.

@sdayman @fritexvz

I am sorry but I haven’t tried and used custom key cache within Cloudflare yet.

  • which I suspect work in some way like while using similar techniques on Nginx php_fastcgi or using Memcached or Redis at the host/origin, with declarative custom cache keys specified for the web application needs …

I would say depending on the usage, that is the reason to have multiple ways to use it.

As I haven’t used a lot the the Cloudflare Workers yet, so cannot tell some good feedback regarding it and the setup.

Promise I will do my best to try that things out for sure and write back ASAP when having more experience.

Until then, I prefer to patiently wait for some reply of other user or customer who has more experience or can recommend you which one should you pick regarding your needs.

Thank you for asking :wink:

@harris @ KentonVarda @cloonan

Hi @spoojary,

If you’re already using a Worker in the request pipeline, then there should be no performance difference at all. If you’re not already using a Worker, then adding one just to set the cache key would incur some small overhead of adding the Worker into the pipeline. In general, this is negligible.

I would recommend whichever solution you find most convenient. If your use case can be fulfilled just with a Page Rule, and you find this maintainable, then I’d stick with that for now.

Harris

Thank you for the reply @harris , Currently, we are using both worker and page rules. for better maintainability we are moving our cache key generating part to page rule custom cache key, is there a way to get Cloudflare generated custom cache key in headers.