Fundamentals 15 min read

What Happens Behind the Scenes When You Enter a URL

The article explains step‑by‑step what occurs when a user types a URL, covering DNS resolution, browser caching, HTTP requests and redirects, server processing, HTML generation, resource fetching, compression, and asynchronous AJAX communication, using Facebook as a concrete example.

Java Captain
Java Captain
Java Captain
What Happens Behind the Scenes When You Enter a URL

When a user types a URL into a browser, the browser first looks up the domain name’s IP address using the DNS system. It checks several caches in order: the browser cache, the operating‑system cache, the router cache, the ISP’s DNS cache, and finally performs a recursive lookup through root and top‑level domain servers.

After obtaining the IP address, the browser sends an HTTP GET request to the server. The request includes standard headers such as

GET http://facebook.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...]
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...])
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: facebook.com
Cookie: datr=1265876274-[...]; locale=en_US; lsd=WW[...]; c_user=2101[...]

.

The server may respond with a 301 Moved Permanently redirect, instructing the browser to use the canonical address (e.g., http://www.facebook.com/). The redirect response looks like:

HTTP/1.1 301 Moved Permanently
Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Location: http://www.facebook.com/
P3P: CP="DSP LAW"
Pragma: no-cache
Set-Cookie: made_write_conn=deleted; expires=Thu, 12-Feb-2009 05:09:50 GMT; path=/; domain=.facebook.com; httponly
Content-Type: text/html; charset=utf-8
X-Cnection: close
Date: Fri, 12 Feb 2010 05:09:51 GMT
Content-Length: 0

.

The browser follows the redirect and sends a second GET request to the www address, for example:

GET http://www.facebook.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, [...]
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; [...])
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Cookie: lsd=XW[...]; c_user=21[...]; x-referer=[...]
Host: www.facebook.com

.

The web server software (e.g., IIS, Apache) receives the request, invokes the appropriate request handler (ASP.NET, PHP, Ruby, etc.), processes any parameters or cookies, accesses databases if needed, and generates an HTML document. The successful response is a 200 OK message such as:

HTTP/1.1 200 OK
Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="DSP LAW"
Pragma: no-cache
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Cnection: close
Transfer-Encoding: chunked
Date: Fri, 12 Feb 2010 09:05:55 GMT

.

The response body is compressed with gzip; the browser decompresses it and begins rendering the page even before the entire document is received. A fragment of the returned HTML looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class="no_js">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-language" content="en" />
...

While rendering, the browser discovers additional resources referenced in the HTML (images, CSS stylesheets, JavaScript files) and issues separate GET requests for each. These resources are served from Facebook’s content‑delivery network (fbcdn.net), which uses Anycast and load‑balancing to serve the files from the nearest edge server.

After the initial page load, the browser continues to communicate with the server via asynchronous AJAX requests. For example, the Facebook chat feature periodically sends a request such as GET http://www.facebook.com/ajax/chat/buddy_list.php … to fetch the online status of friends. This pattern keeps the page dynamic without requiring full page reloads.

In summary, entering a URL triggers a cascade of network operations: DNS resolution, HTTP request/response cycles (including redirects), server‑side processing, HTML generation, resource fetching, compression handling, and ongoing AJAX communication, all of which cooperate to deliver the final web experience.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

HTTPDNSBrowserajaxweb fundamentals
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.