Controlling cacheability of requests with cookies¶
To ensure optimal website performance, the Dropsolid platform employs a caching layer. By default, this layer streamlines requests by removing all incoming cookies. This standard behavior minimizes cache variations and improves the likelihood of serving cached content, leading to faster page load times for users.
However, certain cookies are essential for dynamic content delivery, user-specific experiences, or tracking, and therefore need to reach the backend application. To accommodate this, the platform provides a specific mechanism: cookies prefixed with DS_VARY_ are exempt from the default removal process.
(As an aside, standard session cookies, typically used to maintain logged-in user states, bypass the caching layer entirely to ensure dynamic, user-specific content is always served directly from the application.)
Key cookie handling behaviors¶
- Default Behavior: All incoming cookies are removed before the request is processed by the caching layer.
- Example: A cookie named
my_cookiewill be stripped from the request. - Exception for
DS_VARY_Prefixed Cookies: Cookies whose names begin withDS_VARY_are preserved and passed along to the backend application. - Example: A cookie named
DS_VARY_my_cookiewill be kept and sent to the application.
Impact on caching¶
The distinction between these cookie types significantly impacts how content is cached:
- Standard Cookies (Removed by Default): Since these cookies are removed before reaching the caching logic, they do not influence caching decisions. Requests that differ only by these types of cookies will likely be served the same cached page.
DS_VARY_Prefixed Cookies: These cookies are integral to the cache lookup process. If two requests are identical in all aspects except for the value of aDS_VARY_prefixed cookie (e.g.,DS_VARY_my_cookie), the caching layer will treat them as distinct requests. Consequently, both requests will be passed to the application. This may result in the application generating and the caching layer storing separate versions of the page based on the specific value of thatDS_VARY_cookie.
This DS_VARY_ mechanism provides your application with fine-grained control over caching behavior. By strategically naming cookies with this prefix, your application can instruct the caching layer whether a page should have a shared cache entry (even if certain cookies are present but not prefixed) or if unique cached versions are necessary based on the values of specific DS_VARY_ cookies. This allows for tailoring the user experience by serving dynamic content where needed, while still maximizing performance through aggressive caching for common content.