• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / apache server tutorial (install,config, performance tuning, security, error handling) / how to enable KeepAlive connections in apache nginx wordpress

how to enable KeepAlive connections in apache nginx wordpress

Table of Contents

Toggle
  • What is keep alive in apache & nginx
    • too many keepalive connections
  • How to enable keep alive connections in apache htaccess
    • Edit apache 2.conf
  • How enable  keep alive connections in nginx?
  • enabling keep alive on wordpress?
  • Verifying KeepAlive connections ?
  • KeepAlive effect on performance?

What is keep alive in apache & nginx

keep alive connections between browser and server for a certain amount of time seconds, defined amount of connections.
so server don’t need to establish a connection upon refreshing webpage in browser.
so we save CPU resources.
faster loading for client.

too many keepalive connections

a webpage requests 34-150 requests upoloan loading. based on. files for a wordpress 30-50 avg connections.
js,css,img,html etc. (here 4requests enough to load if you build static site like that)
Low requests low dns lookups, faster connection, lower page size.

How to enable keep alive connections in apache htaccess

apache allows allow rewritting rules, but nginx won’t.
So we can add a htaccess in domain top level directory.
but header modules has to enabled on the server.by default it will in shared, managed hosting.
In vps & cloud

Edit apache 2.conf

KeepAliveTimeout
KeepAlive on;
KeepAliveMaxConnections
reload apache server
service apache2 reload

How enable  keep alive connections in nginx?

by default it will enable.
you can add max connections
keep alive timeouts
another directive called keepalivedisable.
which disables the keep alive.
Context location; http,server, location.
reload or restart nginx .
systemctl restart nginx

enabling keep alive on wordpress?

check it enabled at server level by curl on online curl tools to view headers.
through htaccess
add htaccess to web directory.
Through plugin:
php can do better job printing headers.
so browser can understand it , stops closing connection, encouraged to cache resources.

Verifying KeepAlive connections ?

curl -I https://yourdomain.com
or Chrome devoper tools, f12
reload the page.
select network tab, all>> click on static file like domain.com/dir/file.css
check request headers
there it will be appears.
note: you cannot use add_header directive to print keep alive, there is no variable out there Unless you code it.
like $upstream_cache_status.
also read if modified since, last modified, etag.
browser caching, or caching headers.

KeepAlive effect on performance?

keeping connection alive costs servers threads to use memory & cpu,
apache mpm event module uses seperate threadpool for KeepAlive connections.
nginx threadpool introduced later to fix non synchronous blocking.
values too high or to low depends upon server size, application type, visits type. Measure & set, monitor and fix.

apache server tutorial (install,config, performance tuning, security, error handling)

  • what is If-Modified-Since HTTP header how to add to Wordpress website
  • htaccess tutorial tips for wordpress #redirect #leverage browser cache #Gzip #KeepAlive
  • apache modules list (explained, enable disable)
  • connect to server by SSH client Putty SFTP client winscp LAMP, LEMP nginx apache etc linux
  • Lamp stack install on Ubuntu 20.4 LTS apache, mysql, php 7.4(Debian 9 & Ubuntu 18.04 lts)
  • apache performance tuning mpm-worker vs prefork vs event modules
  • enable caching in apache server (mod cache disk cache) vs fastcgi cache
  • how to enable KeepAlive connections in apache nginx wordpress
  • Cache control Header & expires headers How to set Properly
  • apache2 conf sample explained apache configuration file modules etc
  • restart apache in ubuntu (start | stop | reload | config test) centos debian mac linux windows 10 xampp
  • uninstall apache2 ubuntu in 3 steps Debian

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy