Confirm REST controller cache key generator uses POST body #256

Closed
opened 2022-08-02 00:48:39 +00:00 by jamie · 3 comments
jamie commented 2022-08-02 00:48:39 +00:00 (Migrated from git.hazaar.io)

Cache key generator might not be looking at the POST body which means there are possibly cache issues from the hazaar-forms library which forward API calls as posts.

Cache key generator might not be looking at the POST body which means there are possibly cache issues from the hazaar-forms library which forward API calls as posts.
jamie commented 2022-08-02 00:48:39 +00:00 (Migrated from git.hazaar.io)

assigned to @jamie

assigned to @jamie
jamie commented 2022-08-02 01:48:49 +00:00 (Migrated from git.hazaar.io)

So here's the code in question. As we can see it uses $this->request->getParams() in the key generator which will be populated with POST data if the request is a POST request.

        /*
         * Enable caching if:
         * * The cache object has been created (ie: the cache library is available)
         * * This endpoint has enabled caching specifically
         * * Global cache is enabled and this endpoint has not disabled caching
         */
        $cache_key = ($this->__rest_cache instanceof \Hazaar\Cache
            && ($endpoint['cache'] === true
            || ($this->__rest_cache_enable_global === true && $endpoint['cache'] !== false))
            ? 'rest_endpoint_' . md5(serialize([(array)$method, $params, $args, (($endpoint['cache_ignore_params'] !== true) ? $this->request->getParams() : null)])) : null);

I will still be testing to confirm that POST data is used correctly, but at first glance this is not the issue.

So here's the code in question. As we can see it uses `$this->request->getParams()` in the key generator which will be populated with POST data if the request is a POST request. ```php /* * Enable caching if: * * The cache object has been created (ie: the cache library is available) * * This endpoint has enabled caching specifically * * Global cache is enabled and this endpoint has not disabled caching */ $cache_key = ($this->__rest_cache instanceof \Hazaar\Cache && ($endpoint['cache'] === true || ($this->__rest_cache_enable_global === true && $endpoint['cache'] !== false)) ? 'rest_endpoint_' . md5(serialize([(array)$method, $params, $args, (($endpoint['cache_ignore_params'] !== true) ? $this->request->getParams() : null)])) : null); ``` I will still be testing to confirm that POST data is used correctly, but at first glance this is not the issue.
jamie commented 2022-08-04 07:29:18 +00:00 (Migrated from git.hazaar.io)

Working as expected.

Working as expected.
jamie (Migrated from git.hazaar.io) closed this issue 2022-08-04 07:29:19 +00:00
jamie self-assigned this 2025-09-04 01:14:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/framework#256
No description provided.