> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Wildcard support for cookies in the HTTP cache

> Learn how to use regular expressions for wildcard cookie matching at the cache layer on Platform.sh, improving caching rules and caching performance.

> [!TIP]
>
> This post was originally published on the Platform.sh blog and reflects information from the time of publication.

**Platform.sh now supports regular expressions for wildcard cookie matching at the cache layer.**

Platform.sh Professional includes a dynamic HTTP cache that allows you to cache responses from your application based on the headers and cookies that you specify. This gives you better performance by caching pages or assets which do not change often or per user (if you're on [Platform.sh Enterprise,](https://upsun.com/product/) you already have access to a powerful global application cache and [CDN](https://developer.upsun.com/posts/unknown/what-the-heck-is-a-cdn), so this is not required).

Until recently, you were limited in control the cache to using only fixed cookie names. This meant, for example, that if you were using a session cookie to keep users logged in, that you had to keep track of all the session cookie names used in all your environments or disable the HTTP cache for all users. It also made it difficult to set up useful caching rules when you were using third-party cookies like those set by Google Analytics.

Well, you don’t have to worry anymore, because Platform.sh now supports regular expressions for wildcard cookie matching at the cache layer. This allows you to be very specific about which cookies you cache on and which you let through to the backend, giving you full flexibility in caching.

Users of Drupal, Wordpress and other systems where the cookie name is per user will get the most benefit from this new behaviour, which effectively enables full caching for users who aren’t logged in. Here’s an example for users of Drupal which allows the session cookie through...

```yaml theme={null}
https://{default}/:
    type: upstream
    upstream: app:http
    cache:
        enabled: true
        cookies: ['/^SS?ESS/']
```

Adding a regular [expression match](https://platform.sh/blog/php-80-feature-focus-match-expressions/) to your existing routes is very easy and only takes a couple of minutes. Just remember to test it in a development environment first.

[Full details are available in our documentation](https://docs.platform.sh/configuration/routes/cache.html#cookies).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.