0% found this document useful (0 votes)
19 views

Web Programming I

sharpen your goal

Uploaded by

vuyellaharile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Web Programming I

sharpen your goal

Uploaded by

vuyellaharile
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

2.

2 Web Servers:

• Definition: A web server is software (or hardware) that stores, processes, and delivers
web pages to users upon request. Popular web server software includes Apache, Nginx,
and Microsoft IIS.
• Role of Web Servers:
o Store Resources: Web servers store website files such as HTML, CSS, images,
and JavaScript.
o Respond to Requests: When a server receives an HTTP/HTTPS request, it
processes it and sends back the corresponding resource.
o Serve Dynamic Content: Web servers can interact with databases and server-
side scripts (like PHP or Node.js) to serve dynamic, personalized content.

Request-Response Cycle Example:

1. Client Request: A user requests a page (e.g., www.example.com/home).


o The browser sends an HTTP GET request to the server.
2. Server Processing:
o The server looks for the resource (/home) in its file system or generates the
content dynamically.
o The server processes the request and prepares an HTTP response.
3. Server Response:
o The server sends the requested HTML page back to the browser with a status
code (e.g., 200 OK).
4. Browser Rendering:
o The browser receives the HTML page, fetches any additional resources (CSS,
JavaScript), and displays the page to the user.

3. Introduction to Web Hosting and Domain Names

After understanding how the Web operates, it's essential to know where websites are
stored and how they are accessed.

3.1 Web Hosting:

• Definition:
o Web hosting is the service of providing storage space and access to websites
on the Internet. It allows individuals and businesses to make their websites
accessible to the public.
• Types of Web Hosting:
o Shared Hosting:
▪ Multiple websites are hosted on the same server. It's cost-effective but
may lead to performance issues due to shared resources.
▪ Suitable for small websites with low traffic.
o VPS Hosting (Virtual Private Server):
▪ A single physical server is divided into several virtual servers, each
acting as an independent environment.
▪ Offers better performance and flexibility than shared hosting.
o Dedicated Hosting:
▪ A server is entirely dedicated to one website. It's more expensive but
provides maximum control and performance.
▪ Ideal for large websites with high traffic.
o Cloud Hosting:
▪ Websites are hosted on a network of virtual servers. Cloud hosting is
scalable, allowing resources to grow as traffic increases.

How Hosting Works:

1. You purchase a hosting plan from a web hosting provider (e.g., Bluehost, HostGator,
GoDaddy).
2. The web host provides you with a control panel to upload website files, manage
databases, and configure your site.
3. The host makes your website accessible to the public over the Internet.

3.2 Domain Names:

• Definition:
o A domain name is the human-readable address of a website (e.g.,
www.example.com). It serves as an alias for an IP address.
• Structure of a Domain Name:
o Top-Level Domain (TLD): The extension of the domain name, such as .com,
.org, .net, or country-specific extensions like .cm (for Cameroon).
o Second-Level Domain (SLD): The unique part of the domain name, such as
example in example.com.
o Subdomain: A domain that is part of a larger domain. For example,
blog.example.com is a subdomain of example.com.

Domain Name Registration:

• You need to register a domain name through a domain registrar (e.g., Namecheap,
GoDaddy).
• Registrars provide domain management tools and ensure the domain is linked to the
correct IP address.

3.3 How Domains and Hosting Work Together:

• The domain name directs users to the server where your website is hosted.
• When someone enters your domain name in their browser, DNS translates it to an IP
address and sends the request to the corresponding server.
• The server then serves the website files associated with the domain name.

Week 3: Addressing of Web Documents

In this week, we will focus on how web documents are addressed, how domain names are
resolved via DNS, and the difference between absolute and relative URLs. The following
topics will be covered in detail:

1. Introduction to URLs: Structure and Components

A URL (Uniform Resource Locator) is the address of a resource on the web. Every
webpage, image, video, and file on the web is accessible via a unique URL.

1.1 Structure of a URL

A typical URL consists of several components that describe how to access a specific
resource:

Example URL:
https://www.example.com/path/to/resource?query=parameter#section

Each part of this URL serves a specific purpose:

1. Protocol (Scheme):
o The protocol specifies how the browser should communicate with the server.
o The most common protocols are:
▪ HTTP (Hypertext Transfer Protocol): http:// – standard for accessing
web pages.
▪ HTTPS (Hypertext Transfer Protocol Secure): https:// – encrypted
and secure version of HTTP.
o FTP (File Transfer Protocol) and other protocols may also be used for
different purposes.
2. Domain Name:
oThe domain name (e.g., www.example.com) is the human-readable address of
the website.
o This domain is mapped to an IP address using the Domain Name System
(DNS).
o Structure of a domain name:
▪ Top-Level Domain (TLD): .com, .org, .net, etc.
▪ Second-Level Domain (SLD): example in www.example.com.
3. Subdomain (optional):
o A subdomain can be used to create separate sections or versions of a website.
o Example: blog.example.com or shop.example.com.
4. Path:
o The path (/path/to/resource) specifies the location of a resource on the server.
o It represents the directory and file structure on the web server.
o Example: /about refers to the about page, while /images/logo.png points to an
image file.

5. Query Parameters (optional):


o A query string provides additional data to the server, often used in forms or
searches.
o It's specified by a ? followed by key=value pairs.
o Example: ?query=parameter.
6. Fragment (optional):
o The fragment (e.g., #section) points to a specific section or element within a
web page.
o It's used to scroll the browser to that part of the document.

2. Absolute vs. Relative URLs

When referencing resources within a website, there are two types of URLs to consider:
absolute URLs and relative URLs.

2.1 Absolute URLs:

An absolute URL is the complete URL that includes all necessary information to locate a
resource. It provides the entire path from the protocol to the resource.

Example: https://www.example.com/images/logo.png

• This URL can be used to access the logo.png image from any location on the Internet.
• Absolute URLs are useful when linking to external websites or when you want to
provide a fully qualified path to a resource.

Key Features:

• Always starts with the protocol (http://, https://).


• Full domain name is included.
• Used for linking to resources outside your website.

2.2 Relative URLs:

A relative URL gives only the path to the resource relative to the current page. It does not
include the protocol or domain, making it shorter.

Example: /images/logo.png

• This URL will access the logo.png image relative to the current location within the
website.
• Relative URLs are typically used for internal links within the same website because
they are more flexible and portable.

Key Features:

• Shorter than absolute URLs.


• No protocol or domain is included.
• Easier to manage when moving a website between domains or environments.

Comparison Example:

• Absolute URL: https://www.example.com/about.html


• Relative URL: /about.html

Relative URLs make it easier to move your site from one domain to another because you
don’t need to update every link.

3. DNS and How Domain Names are Resolved

The Domain Name System (DNS) is the system that translates human-readable domain
names into machine-readable IP addresses. This allows users to type a domain name like
www.example.com instead of an IP address like 192.168.1.1.

3.1 What is DNS?

• DNS is essentially the "phone book" of the Internet. It helps convert the friendly
domain names we type into browsers into IP addresses that computers use to
communicate.
• When you enter a URL in a browser, DNS works behind the scenes to resolve the
domain name to its corresponding IP address.

3.2 Steps in DNS Resolution:

1. Browser Request:
o When a user types www.example.com into their browser, the browser first checks
its DNS cache to see if it has a recent IP address for this domain.
2. Local DNS Cache:
If the address isn’t cached, the browser queries the operating system's DNS
o
cache to check for a stored IP address.
3. DNS Resolver:
o If the IP address is not found locally, the request is sent to a DNS resolver
(often managed by the user’s ISP or a public DNS like Google’s 8.8.8.8).
o The resolver checks its cache and, if necessary, queries authoritative DNS
servers.
4. Authoritative Name Server:
o The authoritative DNS server for the domain (managed by the domain's
hosting provider) provides the correct IP address for the domain name.
5. Return to Browser:
o The DNS resolver returns the IP address to the browser, which then uses it to
make an HTTP or HTTPS request to the server hosting the website.

How DNS Works with URLs:

• When a user types a URL, DNS helps the browser find the corresponding IP address.
Without DNS, users would have to memorize numeric IP addresses for every website
they visit.

Example:

• Domain: www.example.com
• DNS resolves this to an IP address: 192.168.1.1
• Browser sends a request to 192.168.1.1 to load the website.

You might also like