Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm setting up development environment of Apache. I prefer to set a environment variable to be local checked out SVN revision number. The environment variable value is then read in PHP code and put in external JavaScript and CSS URL (as cache bustor). As a result, every time I "svn up" my local code, I got updated JavaScript and CSS URL related to the revision number.

For example, current revision number is 2314 and set to $_SERVER['REVISION']. The PHP page will read this $_SERVER['REVISION'] and render external JS link like this http://www.example.com/2314/home.js. Since there is a revision number in the URL, if local revision is updated, browser cache will be busted for easy development.

Is it possible to achieve this in Apache?

Thanks,

-Morgan

share|improve this question
    
You can interact with an svn repository using php-svn (including getting revisions, etc) - the setup I typically use commits to a repository, and uses the post-commit script to update a development copy on the server; php-svn pulls information such as Head revision, etc (alternatively, a post-commit script could just write the revision to a file that php reads) - doesn't address Apache, so not an answer. –  cyberx86 Jul 5 '11 at 14:59

1 Answer 1

up vote 1 down vote accepted

From reading your answer it sounds like this is a client-side issue. Subversion does not support client-side hooks (from what I know) so I would recommend writing a small script similar to the following to perform your update and also update the revision number in a file.

#!/bin/bash
svn update
svn info | grep ^Revision | awk '{print $2}' > svn-revision

Then in your php code you can read in the revision number as follows:

$SVN_REVISION = file_get_contents('/path/to/svn-revision');

I recommend reading the revision number from a file rather than reading from an environment variable. There isn't an easy way to ensure that your current environment is the same a the environment that Apache is running under. Also this ensures that the revision number in the php code survives reboots, etc.

You should set Subversion to ignore the svn-revision file so you aren't checking it in.

svn propset svn:ignore svn-revision .
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.