Skip to content

Performance: High Query Count Due to Default Caching #23

@antonioribeiro

Description

@antonioribeiro

Hi there,

First off, thank you for creating and maintaining this very useful package!

I'm opening this issue to highlight a performance problem related to the package's default caching behavior. By default, caching is enabled, which can lead to a very high number of calls to the cache driver (e.g., Redis or a database) on every request.

For applications that are already heavily cached at the edge (e.g., via a CDN), the performance benefit of this micro-caching is minimal, but the cost is significant. A single page load can trigger hundreds or thousands of cache queries, putting unnecessary load on Redis or the database and slowing down the initial uncached response.

Real-World Impact
To illustrate the impact, I've been debugging a page on my application and found that simply disabling the cache for tailwind-merge-laravel reduced the total number of queries on a single page load from ~1700 down to ~500.

Before:
Image

After:
Image

This is a substantial performance improvemet.

Proposed Solution
To resolve this, I propose adding a configuration option that allows developers to completely disable the cache and also configure the cache store specifically for Tailwind Merge. This provides the flexibility to opt-out of caching in environments where it may harm performance rather than help it, or just move the cache to a different store, if the use-case performs better with cache.

I am submitting a Pull Request alongside this issue that implements this feature.

Thank you for your consideration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions