Skip to content

Commit

Permalink
fix(playback-core): narrow cmcd for cache (#825)
Browse files Browse the repository at this point in the history
For the time being, only send `sid` and `cid` CMCD k/v pairs on requests
(if cmcd is on and using query params). This should improve cache hits
during e.g. seeks and loops due to buffer flushes + refetches.
  • Loading branch information
cjpillsbury authored Nov 15, 2023
1 parent e46fed4 commit 61a4cfe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/playback-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,17 @@ export const setupHls = (
debug,
startPosition,
cmcd,
xhrSetup: (xhr, url) => {
if (preferCmcd && preferCmcd !== CmcdTypes.QUERY) return;
const urlObj = new URL(url);
if (!urlObj.searchParams.has('CMCD')) return;
const cmcdVal = (urlObj.searchParams.get('CMCD')?.split(',') ?? [])
.filter((cmcdKVStr) => cmcdKVStr.startsWith('sid') || cmcdKVStr.startsWith('cid'))
.join(',');
urlObj.searchParams.set('CMCD', cmcdVal);

xhr.open('GET', urlObj);
},
...defaultConfig,
...streamTypeConfig,
}) as HlsInterface;
Expand Down

5 comments on commit 61a4cfe

@vercel
Copy link

@vercel vercel bot commented on 61a4cfe Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

elements-demo-create-react-app – ./examples/create-react-app-with-typescript

elements-demo-create-react-app.vercel.app
elements-demo-create-react-app-mux.vercel.app
elements-demo-create-react-app-git-main-mux.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 61a4cfe Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

elements-demo-nextjs – ./examples/nextjs-with-typescript

elements-demo-nextjs-git-main-mux.vercel.app
elements-demo-nextjs.vercel.app
elements-demo-nextjs-mux.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 61a4cfe Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

elements-demo-vanilla – ./examples/vanilla-ts-esm

elements-demo-vanilla-git-main-mux.vercel.app
elements-demo-vanilla-mux.vercel.app
elements-demo-vanilla.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 61a4cfe Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

elements-demo-svelte-kit – ./examples/svelte-kit

elements-demo-svelte-kit-git-main-mux.vercel.app
elements-demo-svelte-kit-mux.vercel.app
elements-demo-svelte-kit.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 61a4cfe Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

elements-demo-vue – ./examples/vue-with-typescript

elements-demo-vue-mux.vercel.app
elements-demo-vue-git-main-mux.vercel.app
elements-demo-vue.vercel.app

Please sign in to comment.