开发者

File names with version numbers...is it a good idea?

开发者 https://www.devze.com 2023-03-21 13:00 出处:网络
I have this custom-made CSS reset stylesheet that I keep updating and I always mention the date and version number inside so I can keep track of multiple copies.

I have this custom-made CSS reset stylesheet that I keep updating and I always mention the date and version number inside so I can keep track of multiple copies.

Is it a good idea to name my stylesheets using veersion numbers?

For example:

  • example_v1.0.css
  • example_v1.0.1.css

If it is, is it 开发者_运维问答also a good idea for HTML, JS, and PHP files?


It IS a good idea to maintain multiple versions.

However it is not a good idea to maintain multiple versions manually. There are tools to do that, called source control/version control tools, and these tools provide features over and above just maintaining versions.

Some of them include Mercurial, Git, Subversion and CVS.


No!.. Even for small projects use svn!

client: http://tortoisesvn.tigris.org/

server for Windows: http://www.visualsvn.com/server/


It's a good idea if you are extremely worried about caching. Never reusing a file name allows to:

  1. Set expiration headers so the item never expires.
  2. Make sure the browser is not displaying an obsolete version of the file.

It's not so good if it's only a way to replace a real source control tool.


Use some kind of VCS (version control system) instead. It'll save you headache. There's a nice overview of few of them here.


Pfft. No. Use a VCS like everyone else.


It could be a good idea in few situations:
1. You could easily have a preview of new version of a service and the old one for production.
2. You may may be forced to update half of a service or a front page only. It could be easier to have each versions in separate file than a set of hacks in one.

There are soft and hard links too on some filesystems too.

However, if You need a revision control, I would recommend a dedicated software for this purpose. I personally use Git (http://git-scm.com/).


Presumably most of your front end html or php files are going to be using the same style sheet/s so all you have to do is include a link to a version file which then references the actual css files.

<html>
<head>
<?php include ("css-version.html") ?>
</head>
<body>
</body>
</html>

Then in your css-version file will be something like...

<link rel="stylesheet" href="css/my.css?v=01" type="text/css" />

That way you only have to update the version number in css-version file and all the files which include the css-version will reload in browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号