Ryan Griggs
Ryan Griggs

Reputation: 2758

How to update a global version number each time the site is updated?

I have a site that runs on LAMP. I have a global "version number" variable which I manually update to indicate when changes have been made to the site. Changes to this version number trigger alerts to current users to refresh their page to see the newest updates.

Is there a way I could trigger this version to increment automatically each time any of the site's PHP/JS/CSS/etc file(s) has/have changed, without being too resource-intensive (i.e. scanning all files every time the site loads and looking at file modification dates)?

FYI I'm committing changes via SFTP from a text editor.

Upvotes: 0

Views: 39

Answers (1)

Javier S
Javier S

Reputation: 396

If you have shell access in the server web server you could use GIT and commit changes. Then your global version could be the ID of your last commit.

git log --format="%H" -n 1

Upvotes: 1

Related Questions