Web Development

Learn about different topics in modern web development.

Controlling Client-side Caching of Javascript and CSS in Drupal

While updating CSS and Javascript files on a Drupal website, I ran into a problem.  I couldn't force users to see those new versions of the CSS and Javascript files because as we all know, Javascript and CSS files are cached in web browsers.  So that left me with a problem, since the new Javascript files were needed to allow the website to operate properly.

After looking for a solution, I found that Drupal already handles this, it has a mechanism to allow you to control the client-side cache of people visiting your website.

I know what you are thinking, there's no way you can do that.  Well, you can, you are not manipulating your user's cache, you are instead just pointing them to a new URL.  Its much easier to explain in the video:

So you see, even if your CSS or Javascript files do not change contents, you can force the users of your site to grab a new copy from the server by simply passing a dummy query argument that is different from what you currently have.

The way that you can allow this functionality to happen when developing your own custom modules or themes in Drupal is to make sure that you use drupal_add_js or drupal_add_css to add your files.  That is what allows Drupal to track your files and properly append the dummy query argument to the end.

Very tricky, but very effective, and completely eliminated all the problems I had with users complaining of problems every time I did a release and had CSS and Javascript changes.

Assembla now planning to charge for SVN hosting - Review of SVN hosting alternatives

Assembla just announced that they would be charging for private spaces.  Announcement here.

They have a great service, but the only reason I chose them was because they were free.  I currently have 3 different projects up on there so I need to look for another SVN hosting company.  Saved me a bunch of headaches on my collaborative software development projects.

I thought I would use this opportunity to take a quick look at the competition out there, to find an alternative to Assembla for SVN hosting.

1) XP Development Tools

Note that it is eXtreme Programming development tools, not Windows XP development tools, that would be lame.  This sounds like a great option.  Offers up to 5 free subversion repositories.  Also allows unlimited number of repository users.  Also comes with a task list and other tools to manage projects.  I'm going to be getting an account and playing around with this one for sure.

2) Unfuddle

Unfuddle offers some better features for free, including a ticketing system and a max of 2 users and 1 project for free.  $9 per month gets you 4 projects and 10 users.  Here is the plan comparison page.

3) CodeSpaces

CodeSpaces is very similar to Unfuddle, offering 2 users and 1 project for free with ticketing.  For $10 per month, you get 4 users and 3 projects.  Here is the plan comparison page.

4) CVSdude

CVSdude is not only CVS, but actually is SVN hosting by default.  However, the free version only allows 1 user, and has no integrated ticketing support.  Ends up being $15 per month to have 5 users.

5) Bounty Source

This is a site that is designed around collaborative, with the site getting its money from connecting developers together, so it looks like its free for now, includes ticketing, SVN, and essentially unlimited users.  However, you don't have the option of making the project private.  Which is the reason I'm excluding sourceforge.net and google code projects from this list of alternatives.  In my situation, I need to be able to restrict who joins the project.

Google AJAX Libraries API hosts your javascript libraries online

One of the most important tools that we have access to as web developers are open source javascript frameworks and toolkits.  You know, tools like jQuery, prototype, dojo, scriptaculous.

I think you are a lot like me in that you always find it a real inconvenience to always go out and download the latest source, bring it into your development project, and include it in all of your files.  I ALWAYS have different projects using different versions of prototype!

You probably also hate that it takes forever to load all of these toolkits in your webpages.  They are so useful, you can't really design without them, but they increase your page load time a lot.

Well, there are others like you out there, and a good thing that some of them work at google.

Google AJAX Libraries API has approached these problems by hosting these open source javascript libraries and wrapping an interface around them to be able to load the most current version, or even a specific version in the past.  All without actually including any source code locally.  No more storing released versions of prototype in SVN.

This also has the potential to make loading the various javascript libraries take no time!  Let me explain.  The more people that start usin the API, the better chance you have that the javascript library you are using is already in the cache!  You know there are tons of others out there using those tools, why not use that to your advantage and save some page load time.

So you may be wondering if this is hard to use.  Not at all.  Simply include the Google AJAX Libraries API source file, and use google.load.  Here is an example.

  <script src="http://www.google.com/jsapi"></script>
  <script>
    // Load jQuery
    google.load("jquery", "1");
  </script>

I really think Google is on to something here and I hope it catches on!

SEO Keyword Tools

For SEO strategies to work, you must first figure out which keywords you want to use to optimize your search engine hits for.  In many instances, you can probably guess what keywords will drive traffic to your site.  However, for proper SEO keyword choices, we can be smarter than that.  There are a few free SEO keyword tools that exist to help us make the decisions on which keywords to use for SEO.

[adsense:468x60:1:4]

The first SEO keyword tool to mention is from the source of the search engine, Google External Keyword Tool.  By putting in a general search term, this SEO keyword tool will give you the relative advertiser competition and also the average search volumes, all for the google search engine.  This can give you some hints as to which keywords are going to be the most important for driving more traffic to your website.  The competition follows the money, so going into an area with high competition isn't necessarily a bad thing, if you are hoping to make any money by targetted ads.

 

The second SEO keyword tool I will mention is another tool to tell what the relative number of searches are for particular keywords, but this tool isn't specific to the google search engine.  The tool is provided by Wordtracker.  This tool shows the comparitive search volume.  Again, this is great for figuring out which keywords are better than others when you are choosing to optimize.

 

This next tool was built to help tell which keywords that people search for might lead to a product purchase.  This is called commercial intent, and the tool is made by Microsoft AdCenter Labs.  Keywords with commercial intent have a higher chance of leading to a sale on your site for whatever product you are selling.  This might be kind of fuzzy to you, so let me show you a basic example.  Let me throw a couple of search terms at you.  The first one is "free popcorn", and the second one is "popcorn".  This is an obvious example, but as you can guess, the search for "free popcorn" obviously isn't looking to pay for anything.  However the search for "popcorn" could be looking for special popcorn kernels, or salt, or popcorn poppers.  If I put those words into the commercial intent tool, I get a probability of 0.59375 for "popcorn", but only 0.31117 for "free popcorn".  I would not include "free popcorn" as a keyword you optimize for, "popcorn" will be much better.  Or even better, how about "popcorn popper" (0.81871) or even better, "popcorn salt" (0.89281).

Assembla provides SVN and Trac on the web for software development

I have been using open source source code versioning systems for a while now, and really like SVN.  Its easy to setup, easy to use from both Windows and Linux from the developer side through Tortoise SVN and Rapid SVN, and can be accessed through http, which is a big bonus in accessibility over CVS which I had used before.

I've also found myself very interested in what Trac provides as an open source code enhancement/bug/task tracking and ticketing system.  I have used Bugzilla before, but it didn't integrate with SVN to be able to browse source code and tie code changes to tickets, so I felt like I had two separate tools, which made it very easy for me to let Bugzilla get out of date because it was too much overhead to commit changes using SVN and entering the same change into Bugzilla.

What Trac allows is integrating with SVN, and SVN has hooks in the commit process that allow scripting to happen between Trac and SVN so that you can associate a code commit with a Trac ticket.  Absolutely perfect!

But I am a real small developer, I don't have my own server securely attached to the internet that I could modify the apache server configuration to allow SVN support over the web.  I use a hosting company, and hosting companies don't allow you to make those kind of changes.  But I have a great need to be able to collaborate with others, and I love what Trac and SVN together can provide.  What to do?

Then I came across Assembla.  They obviously have had this problem before as software developers, and decided to come up with a solution to it, and best of all, the free offering really supports most small developer teams.  They integrate SVN/Trac together to give you an SVN server over the web you can use.  They allow you to invite other members to your team that you can optionally configure to be private (which I always do).  For me, the Trac/SVN is enough, but they also throw in a Wiki to make it easy to write up documents to aid in development.  All of it is on the web, so there are no servers to maintain, and no remote access issues to figure out.

So now, I feel like I finally have a software development environment that allows me to be productive without needing to worry about setting up my own SVN/Trac server, and I also can collaborate with others very easily.  And all of it for free thanks to Assembla.

Syndicate content