We have two files in header of every web page – a ccs and a javascript file:
<script type="text/javascript" src="/js/scripts.js?1234"></script>
<link href="styles.css?2345" rel="stylesheet" type="text/css" />
Every time we modify a css/javascript file we increase the ?1234 parameter in the end of filename. Recently a member of the team proposed to replace this manual updating (that we have sometimes forgot to do) with PHP code that checks the file modification time itself:
<script type="text/javascript" src="/js/scripts.js?<?php echo filemtime('/js/scripts.js');?>"/>
<link href="styles.css?<?php echo filemtime('styles.css');?>" rel="stylesheet" type="text/css" />
The question is that how much slower (if at all) it makes the requests? Should we do it? We run our system in Linux server on Amazon EC2.
Filetime is slow but using it 2 times in a webpage maybe ok. But I would cache the result and only update it sometime (with a conjob for example).
-> http://ckon.wordpress.com/2008/09/16/filemtime-the-performance-killer/