Best Practices for Reducing Hits

At amazee.io our pricing is a hits-based system that is more flexible and saves you money. You can learn more about why we chose this system and how it works in this article. We are committed to hosting the way we would want to be hosted. Here’s some ways to make sure your hits are an accurate representation of your site traffic.


So what counts as a hit?

Every request from a browser to our servers is a hit. If you use Google Chrome developer tools and load a website you can see how this works: when you visit a website, it loads the HTML and all the picture files and anything else the page needs to run. Each one of these little requests can count as a hit. This differentiates hits from pageviews.


Although this may seem like your hits number will be terribly high, this method of measuring site traffic isn’t inflated after all. This is partly because we are only charging you for the requests to our server and many elements on your site don’t. Elements like the facebook button that pings facebook, for example. The other part of this is that we have a built in feature here at amazee.io that automatically reduces the amount of hits for each site we host.


Cache what you can

As part of our hosting services, amazee.io servers tells browsers to cache images, JS files, and other things (we refer to them as “assets”) not likely to change for up to a month while making sure that the HTML file itself is not cached. This is not a standard drupal feature, it has one cache setting across the board. The reason this works so well is that if you change a picture on your site, a new URL for that picture will be generated and the new picture will be loaded. But if all stays the same, the images are cached for up to a month.


This means as people click around your site and explore it, the images and other static parts of your site that are loaded multiple times won’t count as multiple hits. This also means, simply by hosting your site on amazee.io, you’re making your website faster!

Don’t like this feature? If these cache settings don’t jive with how your site works for any reason they can be easily disabled or configured differently.



One CSS / JS file to rule them all

One thing you, as a developer, can do is to reduce your hits is to make sure to aggregate your CSS and JS files. As you develop sites, you accumulate quite a few CSS and JS files. For each module and custom thing you make another one is generated. By aggregating them into single files, you can make sure that you don’t get a hit for each one pulling from the server individually. On Drupal this couldn’t be easier: you simply have to tick a box enabling CSS and JS aggregation.


If you need more control over what goes into those mass CSS files, or what doesn’t. You can install the Advanced CSS/JS Aggregation module.


Know your website

Another way to reduce your hits is simply to know your site on a deep level. By looking closely at your own site you can get to know what will count as a hit and what will not.

We suggest using the Google Chrome DevTools to keep an eye on what is making requests as you click around your website. You can find more instructions and installation links here.


Remember that for our purposes you should only be looking at what is pinging the actual web server — not other external ones (see here how to filter for these). And remember too that anything that is shown as “from disk cache” or “from memory cache” will not be counted as a hit either.


Use a Content Delivery Network

If your site has a loooooot of traffic you might consider using a CDN. CDNs act as intermediaries, pinging the server for info once and then distributing it to many visitors before needing to pull it again. If you have extremely heavy traffic this might make sense for your company, and certainly would drastically reduce your hits under our pricing model.


There are a couple reasons why using a CDN might not be a good choice for your site. For one thing, because there are sometimes hundreds of CDN servers around the world that you need to go through, for lower traffic sites it might increase your hits. Furthermore, having a CDN is another service to pay and maintain, and another thing that could break your site.


But if it is the right choice for you amazee.io can provide services and support any CDN, whatever that may be.


Our pricing, like everything else we do, is built on how we as developers want to host for developers. If you want to know more about our pricing or any aspect of our hosting services, feel free to hop into our Slack and say hello!


Writer