Blogs

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.

Reason that you cannot have multiple SSL certificates with Apache

I just recently was looking at creating two separate SSL protected domains on an Apache webserver, but ran into a roadblock.  One of the sites (domain2) seemed to be trying to use the SSL certificate that I configured for the other domain (domain1).  SSL worked just fine for domain1, it used the correct certificate.  But domain2 always pointed to domain1's certificate no matter what I did.

It turns out that it isn't possible due to two things.  One being my version of Apache and OpenSSL, and another being that I only have a single IP address for the machine that hosts my sites.

How did I find this out?  A google search for apache multiple ssl virtual hosts eventually brought me to this apache SSL FAQ page: Why is it not possible to use Name-Based Virtual Hosting to identify different SSL virtual hosts?

If I were to still want to host two unique SSL protected domains, I could either get another IP address for my web server so I could create a separate virtual host for that different IP, or I could upgrade to the versions of Apache and OpenSSL that would allow SNI (Server Name Indication) as mentioned in the article above.

Oh well, hopefully you are fortunate enough to be reading this before you go out and buy 2 SSL certificates right away like I did.

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.

Drupal shopping cart using Ubercart

If you are looking for an easy way to implement a drupal shopping cart, using Ubercart is one of your best options.  I came to this conclusion in my article on Drupal shopping cart options.  Many out there might go for the best of breeds model, which leads you to developing your website and integrating a third party shopping cart from scratch, but why do that?  Drupal already has support for Ubercart as a shopping cart.

Drupal Twitter module - new Drupal posts update automatically to Twitter

The Drupal Twitter module is an answer to a problem that I had been looking for a solution to.  A fundamental part of a good traffic creation strategy is to ping social networking sites when you create content on your site.  As a part of that ping process, you want to have a description/title of whatever content you produce and a link back to your website to the full article.  The main purpose is so that you can drive traffic back to your website to consume your content.

How this works with the social networks is that in Twitter for example, everyone that is following you would see a tweet that you just posted to your blog.  But doing this manually every time you post to your blog or create an article would be time consuming.  Luckily, there are automatic pinging module available for Drupal called the Drupal Twitter module.

It works by saving your Twitter account username/password, then every time you post something, it will go out and automatically create a Tweet for you.  Its really simple, I actually found a tutorial to show you how to install the Drupal Twitter module.

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.

Drupal shopping cart options

I have recently started looking at how to handle taking credit card payments for goods or services from a website. And since I implement sites in drupal, I geared my search towards shopping cart implementations in drupal.

So here are my requirements in searching for a shopping cart to use with drupal (or any CMS):

  • Shopping cart must be free and open source.
  • Shopping cart must support multiple payment processing companies to avoid single-sourcing.
  • The module available for Drupal must be stable and have supporting modules around it for customization.
  • Must support taking credit card payments. Other payment options are bonus.
  • Reports on transactions are necessary to track user behavior and optimize revenue. Reporting interface that supports customizations is bonus. Must at least allow exporting data out to generate custom reports.
  • Be able to calculate shipping easily. The world is used to the amazon's and buy.com's, they should expect nothing less at my site.
  • Be able to customize the look and feel of the shopping cart. It shouldn't be branded to look like an advertisement for the shopping cart company.

 

Well yeah I'm kinda picky! I don't think that a small site should have to settle for much less than the big boys!

After looking around Paypal's huge list of supported shopping carts, the one I found that was free, open source, and has great module support in drupal is Ubercart. They support payment processing through Paypal Website Payments Pro and Authorize.net, and others. This enables credit card and check processing, and many eBay shoppers are very familiar with PayPal and probably already have accounts.

And one of the things that can make or break an open source software product for me is the availability and quality of the documentation available either from the open source project itself or the community. After browsing around the documentation directly on Ubercart, it was obvious that the software was designed to be easy to use and well documented.

So I'm really excited because I've found a pure open source solution to a common ecommerce problem. I think I always had a false notion in my head that there were high barriers of entry to making a ecommerce site because of all the fees and cost that would be involved in finding a shopping cart and payment processing method, but that doesn't exist anymore thanks to Drupal and Ubercart. The only cost really involved now is the fees by the payment processor for handling the credit cards and other payment options. More on that another day...

Syndicate content