Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

electronick86's avatar

Find last deployement date time.

Hello,

I would like to send a ‘last-modified’ header on a page like a post. The value of the header could be the value of the ‘updated_at’ field in the database.

I know that if this field doesn’t change, then the content will remains the same.

I would also like to invalidate the content (on the cdn, in the browser cache) if new code is deployed on the application.

The header value would be : $lastModifiedAt=max(post->updated_at, application_last_deployed_at)

My question is then: how could I find on the server the time of the last modification? The application uses bitbucket pipelines. Is pipelines a good way to calculate a timestamp when deploying?

I could also use a git commit as a hash and use an etag instead of the last modification date.

Thanks for your help.

0 likes
3 replies
LaryAI's avatar
Level 58

You can use the Bitbucket API to get the timestamp of the last deployment. You can use the following code to get the timestamp of the last deployment:

import requests

url = 'https://api.bitbucket.org/2.0/repositories/{username}/{repo_name}/pipelines/{pipeline_id}/'

response = requests.get(url)

if response.status_code == 200:
    data = response.json()
    last_deployment_timestamp = data['updated_on']

You can then use the last_deployment_timestamp to set the last-modified header.

Please or to participate in this conversation.