الأسبوع 1 · الوحدة ١ «أساسيات تصميم موقع الويب» (١): هدف الوحدة، البرامج المجانية ومفتوحة المصدر، صفحات الويب الساكنة والديناميكية، الخوادم والسكريبتات · 3 دروس
2
Static or dynamic? Two kinds of web page
ICT Secondary 2 Term 1, Unit 1: pp. 7–13
GoalExplain the difference between a static and a dynamic web page, and why the address alone cannot always tell you which one you have.
New words
static web page · a file stored on the server and sent exactly as it isdynamic web page · a page built by code on the server when it is asked forfile extension · the letters after the dot in a file name, such as html or phpURL · the address that tells the browser where a page is
Explanation
A static page is a ready-made file, usually ending in .htm or .html. The server finds the file and sends it as it is, so every visitor gets the same page until someone edits the file. It may hold text, pictures, tables and links, and the page itself does no calculating. A dynamic page is different: it contains code that the server runs when the page is requested. The code can read a record from a database or react to what the visitor typed, so the result can change from one visitor to the next, or from one hour to the next. For example, a page that shows “the books you borrowed” must be dynamic, because the list is different for each member. Often the end of the address, such as .php, hints at the kind of page. It is only a hint: some addresses hide the extension, so you cannot always tell. What matters is whether the server builds the page or just sends a file.
Static page
Dynamic page
Who makes the page?
nobody: the file is ready
code on the server, at the request
Same for every visitor?
yes
no, it can change
Usual file
.html or .htm
.php
Example
About the club
Books this member borrowed
Worked examples
Page
Visitor
What arrives
about.html
Mona
the ready file
about.html
Omar
the same file
my_books.php
Mona
a list of 3 books
my_books.php
Omar
a list of 1 book
The club site has about.html and my_books.php. Mona asks for about.html at 10:00 and Omar at 11:00: both receive the same file. Then each asks for my_books.php. The server code looks up each member in the database, so Mona sees three books and Omar sees one. The first page is static, the second dynamic.
Address ends in
What can we say?
books.php
probably dynamic
news.html
probably static
page?id=4
extension hidden: cannot say
Salma reads three addresses. The first ends in books.php, the second in news.html and the third is www.nile-club.example/page?id=4. The first is probably dynamic and the second probably static. For the third, the address hides the extension, so she cannot say; she must find out how the server makes the page.
Class activity
Invent a small site for a reading club with six pages (for example: home, about, contact, list of books, a member’s loans, a page that shows today’s date). Write for each page whether it can be static or must be dynamic, with one reason.
Practice
1
A page shows the same text to everyone and is stored as club.html. Static or dynamic?
Static: the server sends the file as it is.
2
Why must a page that shows today’s date be dynamic?
The date changes, so code on the server must work it out each time the page is asked for.
3
Is the ending .php always proof that a page is dynamic? Explain.
No, it is only a hint, and other addresses hide the extension. What matters is whether the server builds the page.
4
Name one thing a dynamic page can do that a static page cannot.
For example: show a stored record from a database, or react to what a visitor typed.