Set Cache-Control and Last-Modified for pipelines/stage
What does this MR do and why?
This MR adds Last-Modified
and Cache-Control
headers to pipelines#stage
(For example, https://gitlab.com/gitlab-org/gitlab/-/pipelines/1091955371/stage.json?stage=lint)
You can trigger this request it in the UI on the pipelines page (!138226 (merged))
I've noticed that the response generation for this action is quite slow, so when you click it more than once, you wait a long time. For example, this is a one-off execution of StageSerializer
on production:
[ gprd ] production> pipeline = Ci::Pipeline.find(1091955371)
=>
#<Ci::Pipeline:0x00007f3b1546d320
...
[ gprd ] production> stage = pipeline.stage('lint')
=>
#<Ci::Stage:0x00007f3b07e08e10
...
[ gprd ] production> current_user = User.find_by(username: 'dgruzd')
=> #<User id:5054237 @dgruzd>
[ gprd ] production> project = pipeline.project
=> #<Project id:278964 gitlab-org/gitlab>>
[ gprd ] production> Benchmark.realtime { StageSerializer.new(project: project, current_user: current_user).represent(stage, details: true, retried: false); nil }
=> 16.071687005460262
I haven't seen such numbers again. Usually it's below 10s
By setting Last-Modified
and Cache-Control
, we'd avoid performing this expensive serialization if client's browser already has it cached.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.