When you’re on shared hosting, the resources of the server are shared between multiple accounts. So it’s important to choose a plan that gives you enough resources for your site. Here are some tips:
- Take into account your site’s traffic levels and bandwidth needs when choosing a plan. Avoid plans that are overloaded with too many accounts.
- Go for plans with more RAM, CPU cores, and SSD storage if your site has high traffic or complex functions. Basic plans may struggle with a resource-intensive site.
- Check if the host provides resource limits and guaranteed resource allocations for each plan. Some limit bandwidth, CPU usage etc while others guarantee a minimum.
- Know exactly what’s included in each plan – disk space, bandwidth, parked/addon domains, email accounts etc. Get the specifics.
- Look for plans with caching and content delivery network (CDN) options built-in to handle spikes in traffic.
Choose the Right Web Host
Your web host’s infrastructure, policies and technical support have a big impact on your site’s performance. Here are tips on choosing the right one:
- Check reviews and uptime status of hosts before selecting one. Avoid hosts with poor reviews or history of frequent downtime.
- Choose a host with multiple data centers in different geographic regions for redundancy and failover.
- Check the host’s saturation level i.e. the number of accounts on their servers. Too many accounts can degrade performance.
- Go with hosts using modern infrastructure – SSD storage, cloud hosting, load balancing etc for optimal speed.
- Look for hosts with proactive resource monitoring and upgrading. They should scale your account if needed.
- Don’t use free or extremely cheap hosting plans for a business site. These are oversubscribed and have poor support.
- Make sure the host has 24/7 technical support via live chat, phone and tickets for a quick response time.
Use a Content Delivery Network (CDN)
A CDN stores cached copies of your site’s static assets across multiple geographical locations. This speeds up loading and provides better uptime.
- Use CDN for hosting images, CSS files, JS scripts, fonts etc. These static assets load faster from the CDN.
- Choose a CDN network that has points of presence near your site visitors for faster local access.
- Make sure your CDN uses HTTP/2 and GZIP compression for faster transfer of assets.
- Set optimal cache expiration times on your CDN for updated assets. Longer times improve caching but can cause stale content.
- Configure the CDN to compress your assets for smaller file sizes – images, scripts, CSS etc.
- Use CDN-provided services like image optimization and manipulation to reduce file sizes.
- Integrate the CDN directly with your CMS or site scripts for automated caching of assets.
Enable Caching in your CMS
Caching stores rendered web pages, database queries and objects in memory for faster reuse. Enable CMS specific caching for big performance gains.
- In WordPress, use a caching plugin like WP Rocket or enable Memcached. Tweak settings for optimal caching.
- For Drupal, install the Internal Page Cache or Memcache module with optimal caching times.
- In Joomla, enable System – Cache settings. Use conservative time durations and memory limits.
- For other CMSs like Magento, optimize Cache Storage Management and Backend Caching Cache Settings.
- Ensure caching is enabled for database queries, page fragments, images and other assets.
- Use object caching over file system caching for faster read-write speeds if your host supports it.
- Find optimal caching duration times for your site. Too long causes stale content while too short reduces gains.
- Purge caches when content is updated. Use cache reset tools provided by the CMS and hosting control panel.
Minify CSS, JS and HTML
Minification removes unnecessary characters from code like white space, comments etc to reduce file size. This speeds up page loads.
- Use tools like HTMLMinifier, CSSNano and UglifyJS to minify HTML, CSS and JS files respectively.
- Configure your CMS to minify assets on build or deploy scripts. Many provide minification modules or settings.
- Use a caching plugin like WP Rocket in WordPress to automatically minify code. Enable options during setup.
- For manual minification, automate the process using build tools like Grunt or Gulp. Add minification tasks.
- Ensure minification doesn’t break your source code. Test pages after minifying to catch issues.
- Combine multiple CSS and JS files into one using build tools for fewer HTTP requests. Enable concatenation in caching plugins.
- Load minified assets using CDNs and caching for faster repeat access. Avoid minifying on every page request.
Images often account for most of a page’s size. Optimizing them gives big bandwidth savings and speed gains.
- Use tools like ImageOptim and Kraken.io to optimize images – compress JPGs, remove EXIF data etc.
- Resize and crop images to exact dimensions needed on site, rather than scaling down via HTML/CSS later.
- Serve different sized images for mobile vs desktop screens. Use srcset and sizes attributes.
- Use WebP images supported on modern browsers for 25-35% smaller sizes vs JPG/PNG. Provide fallbacks.
- Use CSS sprites by combining multiple images into one file. Reduces HTTP requests.
- Display vector icons like SVG in CSS rather than icon fonts which have a bigger file size.
- Replace embedded images with links to original files so they can be cached effectively.
Enable GZIP Compression
GZIP compresses text content before sending from the server. This reduces page size with a little CPU overhead.
- Ensure your web host has GZIP compression enabled at the server level. Many have it on by default.
- Verify GZIP is working by checking HTTP response headers or using tools like GTmetrix.
- Set optimal compression levels. Maximum compression causes high CPU usage. Leave images uncompressed.
- Ensure caching layers – CDNs, server caches, browsers etc are configured to cache compressed assets.
- Avoid compressing the same assets multiple times in the delivery chain. Apply GZIP only once.
- Use tools like mod_pagespeed and Gunzipper for automatic GZIP of assets from your origin server.
Reduce HTTP Requests
Avoiding too many separate HTTP requests for page assets boosts performance. Follow these tips:
- Embed small images directly into CSS sprites. Avoid separating them into separate files.
- Inline small CSS and JS code directly in the HTML instead of separate files.
- Load code for above-the-fold content first. Defer non-critical JS using async or defer attributes.
- Avoid HTTP requests to third party code and widgets you don’t really need.
- Cache assets locally using manifest files or a service worker to eliminate requests after first load.
- Use HTTP/2 server connection multiplexing to retrieve multiple assets over a single connection.
Enable Keep Alive
Keep-alive allows multiple requests over a single TCP connection. This avoids overhead of creating new connections.
- Ensure your web server has HTTP keep-alive enabled to reuse connections between assets.
- Configure keep-alive timeout durations in Apache/Nginx to find an optimal value for your site.
- Use HTTP/2 instead of HTTP/1.1 if possible for more efficient use of keep-alive connections.
- Verify if keep-alive is enabled by inspecting HTTP request and response headers.
- Check your site scores on keep-alive using tools like GTmetrix site speed tests or Chrome DevTools.
- If using a load balancer, enable keep-alive between the load balancer and your web servers.
- For REST APIs, use keep-alive for multiple requests within the same user session.
Configure Caching Headers
Caching headers tell clients (browsers, CDNs) how to cache resources. Proper headers boost caching efficiency.
- Set Last-Modified/Expires headers for static assets like images, CSS, JS files to improve browser caches.
- Use Cache-Control headers like max-age and public/private to control downstream caching.
- Validate caching with tools like Fetchbot to verify headers are properly configured.
- Set ETags and If-None-Match headers to enable browser caching of unchanged content.
- Use tools like Expire Headers to analyze existing headers and suggest new values.
- Avoid caching pages with sensitive content using Cache-Control: no-store header.
- Set Cache-Control: no-cache for dynamic assets that change frequently and shouldn’t be cached.
Improve Database Efficiency
Optimizing database usage improves performance and reduces load. Follow these tips:
- Tune your database server for optimal memory usage, query caching and faster I/O.
- Index tables and columns used frequently in WHERE, ORDER BY and JOIN clauses.
- Avoid expensive JOINs and subqueries. Optimize slow queries using EXPLAIN and profiling.
- Use caching for frequently used queries like latest blog posts, categories etc.
- Reduce trips to database by caching objects in memory using memcache or Redis.
- Use a CDN to serve cached data for popular queries like top products.
- Limit post sizes and revisions stored to reduce database bloat and improve performance.
Choose Faster Web Hosting Hardware
Using faster processors, RAM and drives improves performance. When selecting hosting or upgrading, look for:
- Modern multi-core Intel or AMD CPUs with higher clock speeds and cache.
- More RAM to cache and serve content faster, at least 4-8 GB.
- NVMe or SSD drives instead of HDD for faster read/write speeds.
- Latest generation virtualization platforms like KVM with dedicated resources.
- Multiple uplinks and bandwidth to handle high traffic load.
- Hosting plans with fewer accounts on each server to minimize resource sharing.
- Minimum of 1 Gbps network interfaces and internal components.
- Solid state drives for database storage due to low latency and high IOPS.
Analyze and Address Bottlenecks
Identify weak points hurting performance using web debugging tools:
- Audit site using Google PageSpeed, WebPageTest or Chrome DevTools to pinpoint problem areas.
- Install Real User Monitoring tools to identify issues faced by visitors like slow page loads.
- Use APM tools like New Relic to find hardware bottlenecks – RAM, CPU, database etc.
- Monitor server resources like bandwidth, disk I/O, CPU usage to identify constrained areas.
- Profile database queries, code execution with debugging tools to find expensive operations.
- Test site under heavy simulated loads using load testing tools to uncover scaling issues.
- Check for misconfigured or missing caching headers, keep-alive issues etc using Fetchbot.
Offload Processing with a Reverse Proxy
A reverse proxy like Varnish caches pages and serves them faster:
- Use a reverse proxy to cache rendered pages, take load off application servers.
- Insert a reverse proxy in front of your web server using caching rules for performance gains.
- Configure proxy TTL rules or utilize cache invalidation approaches like bans and purges.
- Serve cached pages directly from proxy for anonymous visitors while bypassing cache for logged in users.
- Offload SSL processing, compression, caching from origin servers to the proxy layer.
- Accelerate dynamic content by caching database queries, API responses and fragments of pages.
- Use ESI for edge side includes of personalized content into cached pages.
Rewrite and Redirect Unoptimized URLs
Unoptimized URLs cause unnecessary redirects and load. Here are ways to improve them:
- Shorten long URLs to minimize size. Remove unnecessary query string parameters, IDs etc.
- Avoid chain redirects by mapping old URLs directly to new ones using server rewrite rules.
- Cache redirected URLs on the server side whenever possible to avoid hits to application.
- Use single domain vs multiple subdomains to utilize cookies and minimize redirects.
- Redirect multiple domains to a primary one using canonical URLs if managing several domains.
- Redirect mobile users to dynamically served pages instead of completely separate sites.
- Provide rename rules for resources that get updated like CSS, JS files to prevent caching issues.
Setup a Staging Environment
A staging server replicates production and allows testing deployments:
- Use a staging environment to test major updates and check performance before deploying to live site.
- Ensure staging server replicates live infrastructure – OS, software versions, caching setup etc.
- Script deployments to staging to test automation and avoid variances from live environment.
- Route a portion of production traffic to staging using splits or canary deployments for testing.
- Monitor performance metrics like speed, errors and hardware usage on staging to detect problems.
- Use feature flags or branching to control rollout of new features from staging to subsets of visitors.
- Deploy to staging first to test infrastructure and code changes before going live.
Optimizing Shared Hosting Summary
Optimizing a site hosted on shared infrastructure presents challenges but can be managed by choosing the right hosting plan, efficient caching, improving code efficiency, database optimizations and using staging deployments to test changes. Pick the solutions that provide the best ROI for your site’s traffic levels and growth.