perf: limit cookie parse only on some cookie

Open
#126 0 comments 1 reaction 0 assignees View on GitHub

@cesco69 is already working on this.

Since Apr 15, 2025.

  • #127 by @cesco69 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
backend

Research direction

Start at the cookieParser middleware entry point and review how request Cookie headers are parsed. Check existing option-related tests, then define completion as an option that limits parsing to selected cookies, with a regression test covering the API_TOKEN example.

Written by the indexing model from the issue text.

Description

Hi, in my express I use only 1 cookie (API_TOKEN), but client side send varius cookie eg:

_ga_M9MSXKVJN9=XXXX; 
_ga_W98228BE06=XXXX; 
_gid=XXXX; _ga=XXXX; 
_gcl_au=XXXX; 
_ga_5MFMLYZHT2=XXXX; 
rxVisitor=XXXX; 
_ga_K4Y50QD36K=XXXX; 
dtCookie=XXXX; 
dtSa=XXXX; 
rxvt=XXXX; 
API_TOKEN=XXXX;

the _g* cookies are Google Analitycs / Google Tag Manage
the _dt* and rx* cookies are Dynatrace
the API_TOKEN is the only one used by my express!

Parsig all those cookies on each request has a performance impact!

The idea is introduce an option for limit the cookie parsing on a limit numer of cookies, eg.:

app.use(cookieParser({null, {
   allowedCookie: ['API_TOKEN']
}}))
Dominant language
JavaScript
Stars
2k
Forks
237
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from expressjs/cookie-parser

All issues in expressjs/cookie-parser

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.