Skip to content

Commit

Permalink
Attempt to reduce unnecessary accesses to data files (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarr committed Feb 18, 2024
2 parents 60bc8b5 + 57394bf commit 757dc03
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/frontend/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ export function renderProjectDataOverview(
)}</p></td>
<td>${row.hostnames}</td>
<td class="num-col">${row.runs}</td>
<td class="num-col"><a href="/${projectSlug}/data/${row.expid}">${
row.measurements
}</a></td>
<td class="num-col"><a rel="nofollow"
href="/${projectSlug}/data/${row.expid}">${row.measurements}</a></td>
</tr>`);
}

Expand Down
25 changes: 22 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,34 @@ router.get('/status', async (ctx) => {
ctx.type = 'text';
});

router.get('/robots.txt', async (ctx) => {
ctx.body = `User-agent: *
Disallow: /status
Disallow: /*/data*
Disallow: /rebenchdb*
`;
ctx.type = 'text';
});

router.get('/:projectSlug', async (ctx) => renderProjectPage(ctx, db));
router.get('/:projectSlug/source/:sourceId', async (ctx) =>
getSourceAsJson(ctx, db)
);
router.get('/:projectSlug/timeline', async (ctx) => renderTimeline(ctx, db));
router.get('/:projectSlug/data', async (ctx) => renderProjectDataPage(ctx, db));
router.get('/:projectSlug/data/:expId', async (ctx) =>
renderDataExport(ctx, db)
);
router.get('/:projectSlug/data/:expId', async (ctx) => {
if (
ctx.header['X-Purpose'] === 'preview' ||
ctx.header['Purpose'] === 'prefetch' ||
ctx.header['X-Moz'] === 'prefetch'
) {
ctx.set('Cache-Control', 'must-revalidate');
ctx.status = 425; // HTTP Code for 'Too Early'
return;
}
return renderDataExport(ctx, db);
});
router.get('/:projectSlug/compare/:baseline..:change', async (ctx) =>
renderComparePage(ctx, db)
);
Expand Down

0 comments on commit 757dc03

Please sign in to comment.