I was wondering how to force a client to download Javascript and CSS files in Yii. I have seen that some achieve this by referring to the files by a fake field like http://website.com/r1/style.css where r1 is just something ignored at the server level (through .htaccess for example) but the browser is unaware and would therefore download it again. For instance if you made changes to js or css files you would change r1 to r2.
Does Yii have any solutions or work arounds like this?
The first step is to check which headers your Web server is sending alongside the files.
You will look for cache directives that instructs the browsers to cache the file for too long (wanted in production, but not in development).
You could use Etags or Last-Modified instead during the development.
Once the browser has it cached already, a solution that is similar to the one you listed, but simpler, is appending a query string to the url. For example: http://example.com/style.css?v2
I assume at this point that there isn’t a better way than find-replace to increment these “version numbers” in all of the script tags?
You might have a version control system do that for you? Most version control systems have a way to automatically inject the revision number on check-in for instance.