Blog

Avatar Jake

Cloudflare and why you should use it

Cloudflare is a FREE system that acts as a proxy between your visitors and your server. By acting as a proxy, Cloudflare caches static content for your site, subsequently lowering the number of requests to our servers while allowing visitors to access your site.

Okay then, that sounds good – What else can it do for me?

  • Site Performance Improvement: Cloudflare has proxy servers located throughout the world. Proxy servers are located closer to your visitors, which means they will likely see page load speed improvements as the cached content is delivered from the closest caching box instead of directly off our server. There is a lot of research showing a correlation between the speed of a site and the length of time that a visitor stays.
  • Bot and Threat Protection: Cloudflare uses data from Project Honey Pot and other third party sources, as well as the data from its community to identify malicious threats online and stop the attacks before they even get to your site. You can see which threats are being stopped through your Cloudflare dashboard.
  • Spam Comments Protection: CloudFlare leverages data from third party resources to reduce the number of spam comments on your site
  • Alerting Visitors of Infected Computers: Cloudflare alerts human visitors that have an infected computer that they need to take action to clean up the malware or virus on their machine. The visitor can enter a CAPTCHA to gain access to your site.
  • Offline Browsing Mode: In the event that our server is unavailable, visitors should still be able to access your site since CloudFlare serves the visitor a page from its cache.
  • Lower CPU Usage: As fewer requests hit our server, this lowers the overall CPU usage of your account.
  • New Site Stats: You have good tools to evaluate human traffic coming to your site, but no insight into search engine crawlers and threats. With Cloudflare, now you do.
  • DNS Zoning: Easily update and manage your DNS entries from Cloudflare directly, and choose whether to bypass or pass through Cloudflare with a click of a button

Wow JT, that’s not bad at all… Any cons? Well, just a few – but not enough to outweigh your decision to proceed.

  • Cloudflare may affect internal statistic programs that read directly from Apache logs (Cloudflare will not affect web-based analytic programs that use JavaScript like Google Analytics.) While your logs will reflect fewer requests to your server and therefore lower load, the experience to your visitors should be unaffected.
  • Cloudflare caches static content from your site. While this reduces the load on your server, it means that if you make a change to an existing static file, like an image, there may be a delay before the change appears. While you are updating your site, you can put Cloudflare in Development Mode so changes appear immediately.
  • Cloudflare’s basic mode cannot handle SSL certificates. If you need to use an SSL certificate, that part of your site needs to be on a sub-domain that is not protected.

So what are you waiting for? Sign up for Cloudflare and give it a try.

Avatar Jake

PowerShell Tutorial: A look at Invoke-WebRequest & Invoke-RestMethod

Invoke-WebRequest & Invoke-RestMethod are, in my opinion, one of the greater functions of PowerShell. It is simple, but can provide a great amount of finesse when working on automation projects.

Getting started isn’t hard at all, and you’re most likely on a supported operating system like Windows 10 or Windows Server 2012 R2 and above.

Starting off simple, we can run Invoke-WebRequest to test an endpoint, as well as obtain some raw content/headers, etc. It will always attempt to parse HTML, not so much the data. With the  -UseBasicParsing switch, it’ll do some RegEx HTML parsing, without this switch it reverts to the Internet Explorer COM API to parse the target.

Invoke-WebRequest -Uri 'https://jsonplaceholder.typicode.com/posts/1'


You can see that we’ve now been returned a number of parameters which can be used to debug, or test connectivity.

OK, so let’s try the same endpoint – but this time using Invoke-RestMethod.

Invoke-RestMethod 'https://jsonplaceholder.typicode.com/posts/1'


That looks much better, doesn’t it? The difference is that Invoke-RestMethod has the capability to support JSON and XML content. It will attempt to detect the right decoder and does NOT support HTML (except if it is XML compliant).

The differences are apparent, and there will be use cases for both. For example, Invoke-WebRequest can be used for automating website tests and outputting the results, whereas Invoke-RestMethod can be used to facilitate the exchange of data more simply whether that is exporting to a CSV, writing directly to a SQL table or creating middle-ware to facilitate connectivity between multiple systems.