How to Keep Your Site Fast on Cheap Shared Hosting

To keep a site fast on shared hosting, treat the plan as a fixed budget of CPU, memory and concurrent connections, and spend it deliberately. Most shared-host slowdowns are not caused by the plan itself but by work the site does that it does not need to do, and almost all of that work is under your control.

Shared hosting means your PHP processes, database queries and disk reads compete with other tenants on the same machine. You cannot change the kernel, the disk scheduler or how many neighbours you have. What you can change is how much of each request you spend: how many queries fire, how much gets loaded per page, and how often the server has to do the same expensive thing twice. The techniques below work on any shared plan because they reduce the work before the request ever reaches the bottleneck.

Measure first, so you know what to fix

Before touching anything, find out where the time goes. Turn on slow request logging in PHP so the server records any request that exceeds a threshold. In php.ini or a per-site .user.ini, set the slow log and a threshold in seconds:

request_slowlog_timeout = 2
slowlog = /home/you/logs/php-slow.log

After a day of traffic, read the log. Each entry shows the script and a stack trace of where the process was when the timer fired, which frequently points straight at a slow query or an outbound HTTP call. For database work, enable the slow query log on your MySQL or MariaDB instance if the host allows it, and check EXPLAIN on the queries it reports. A missing index on a column used in WHERE or ORDER BY is the single most common cause of a page that was fine at low traffic and crawls once the table grows. You can confirm an index is being used with:

EXPLAIN SELECT id, title FROM posts WHERE status = 'published' ORDER BY created_at DESC LIMIT 20;

Look at the key column in the output. If it is NULL while the row count is large, the query is scanning the table and the fix is an index, not a bigger plan.

Cut the work per request

Every dynamic request on shared hosting costs a PHP worker, and workers are the scarcest resource. Reduce the number of requests that need PHP at all. Static assets should be served by the web server directly, with long cache lifetimes set in .htaccess or the equivalent config, so repeat visitors do not revalidate them on every page view:

<FilesMatch "\.(css|js|jpg|png|svg|woff2)$">
  Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>

Version your asset filenames (a hash in the name) so you can serve them as immutable without worrying about stale copies. For the HTML itself, send a short Cache-Control and use a conditional request check so unchanged pages return 304 Not Modified instead of rebuilding. Enable output compression with mod_deflate or your server's equivalent; text compresses well and the saving is real on mobile connections.

Inside the application, cache what is expensive and repeated. Object caching in memory (APCu is often available on shared plans, Redis sometimes) removes repeated database reads for the same data. Page caching, even to disk, turns a full PHP render into a file read for anonymous visitors. The rule is simple: if a page looks the same to every logged-out visitor, it should not be rebuilt on every request. Invalidate the cache on write, not on a timer, so content stays correct.

Keep site fast on shared hosting as traffic grows

As traffic rises, the failure mode changes from slow pages to refused connections. Shared hosts cap concurrent PHP processes per account, and when they are all busy, new requests queue or fail. Watch your process count and queue depth, and make sure long-running work does not hold a worker. Move image resizing, email sending and report generation out of the request cycle into a background job or a cron task. A request that returns in a fraction of a second frees the worker for the next visitor.

Set sensible timeouts so a stuck upstream call cannot pin a worker indefinitely. In PHP, cap the socket and total execution time; in your HTTP client, set a connect timeout and a read timeout. If your site calls a third-party API on page load, cache that response and serve the cached copy when the API is slow or down, rather than letting the page wait. A circuit breaker that fails fast is worth more on a shared plan than any amount of tuning elsewhere.

Finally, keep the stack lean. Disable plugins and modules you do not use, because each one adds startup cost to every request. Audit cron jobs so they do not overlap or run during peak hours. Trim autoloaded code and avoid loading large libraries on pages that do not need them. These changes are boring but they compound, and they are the difference between a plan that stays usable as you grow and one that forces a migration you did not plan for.

Start with the slow log and the query plan, fix the one or two things they point at, then re-measure. Add caching where the same work repeats, push background work off the request path, and revisit the numbers after each change so you know what actually helped. That loop, run honestly, will keep a budget shared plan fast far longer than any single trick.

Related articles

Subscribe to our newsletter

Get the latest hosting tips, performance insights, and industry news.