8000 Increasing size of cache for Hash Response in Symfony reverse proxy · Issue #356 · FriendsOfSymfony/FOSHttpCache · GitHub
[go: up one dir, main page]

Skip to content
Increasing size of cache for Hash Response in Symfony reverse proxy #356
@tomaszmadeyski

Description

@tomaszmadeyski

There's file which stores cache for Hash Response (_fos_user_context_hash request). By default Vary is set to ['Cookie', 'Authorization']. Let's imagine we have 10 anonymous users with different session (Cookie). It will result in 10 entries with the same X-User-Hash. The issue is that old (stale) entries are not removed.

Here is unserialized array from cache for HashResponse (irrelevant data is removed for easier overview):

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [cookie] => Array
                        (
                            [0] => eZSESSID=4id3umajrf71hnn5pp2dufu8j7
                        )
                )
            [1] => Array
                (
                    [x-user-hash] => Array
                        (
                            [0] => 5945886524019aefc21a0e99486455ed340b913f23d342bdc6d7459b1a67eeef
                        )
                    [date] => Array
                        (
                            [0] => Tue, 06 Jun 2017 08:36:40 GMT
                        )
                    [cache-control] => Array
                        (
                            [0] => max-age=30, public
                        )
                )
        )
    [1] => Array
        (
            [0] => Array

639D
                (
                    [cookie] => Array
                        (
                            [0] => eZSESSID=v43eimfa20v9sdgijeb2at4up2
                        )
                )
            [1] => Array
                (
                    [x-user-hash] => Array
                        (
                            [0] => b1731d46b0e7a375a5b024e950fdb8d49dd25af85a5c7dd5116ad2a18cda82cb
                        )
                    [date] => Array
                        (
                            [0] => Tue, 06 Jun 2017 08:36:01 GMT
                        )
                    [cache-control] => Array
                        (
                            [0] => max-age=30, public
                        )
                )
        )
    [2] => Array
        (
            [0] => Array
                (
                    [cookie] => Array
                        (
                            [0] => eZSESSID=nj7ru5lr10pt87jmfvgb1c5qf1
                        )
                )
            [1] => Array
                (
                    [x-user-hash] => Array
                        (
                            [0] => b1731d46b0e7a375a5b024e950fdb8d49dd25af85a5c7dd5116ad2a18cda82cb
                        )
                    [date] => Array
                        (
                            [0] => Tue, 06 Jun 2017 08:27:28 GMT
                        )
                    [cache-control] => Array
                        (
                            [0] => max-age=30, public
                        )
                )
        )
    [3] => Array
        (
            [0] => Array
                (
                    [cookie] => Array
                        (
                            [0] => eZSESSID=rcpnur318ub47rgeevi9mlq2f5
                        )
                )
            [1] => Array
                (
                    [x-user-hash] => Array
                        (
                            [0] => b1731d46b0e7a375a5b024e950fdb8d49dd25af85a5c7dd5116ad2a18cda82cb
                        )
 
                    [date] => Array
                        (
                            [0] => Tue, 06 Jun 2017 08:25:17 GMT
                        )
 
                    [cache-control] => Array
                        (
                            [0] => max-age=30, public
                        )
                )
        )
)

First entry is for logged in user so there's different x-user-hash then in other entries. All other entries are for anonymous users coming from different sessions resulting in same x-user-cache but as you can see entries [2] and [3] are stale (according to date and short max-age set to 30 seconds) and could / should be removed.

The result is that this file keeps growing together with number of users: after performing stress tests with ~5000 users file had ~7MB.

Would it be possible to add invalidation for stale cache entries in Hash Response cache?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0