مبانی طراحی وب How the Web works? وب چگونه کار میکند؟ learning objective هدف یادگیری In this chapter you will learn در این فصل یاد خواهید گرفت What is web? وب چیست؟ How does the web works? وب چگونه کار می کند؟ What is a web server? یک وب سرور چیست؟ What is a browser? مرورگر چیست ؟ Internet vs. Web اینترنت در مقابل وب • The Internet is network of • اینترنت شبکه ای از رایانه های متصل است که connected computers that میلیون ها نفر را در سراسر جهان به صورت electronically connects millions .الکترونیکی به هم متصل می کند people of world wide. این یک تالش،• هیچ شرکتی صاحب اینترنت نیست • No company owns the Internet, it is مشترک است که توسط سیستمی از استانداردها و a cooperative effort governed by a .قوانین اداره می شود system of standards and rules. • البته هدف از اتصال کامپیوترها به یکدیگر • The purpose of connecting برقراری ارتباط و اشتراک گذاری اطالعات computers together, of course, is to communicate and share information What is Web? وب چیست؟ • The Web (originally called the World ،وب (که در اصل وب جهانی نامیده می شود • Wide Web, thus the www in site در آدرس های سایت) بخشی ازwww بنابراین addresses) is part of the Internet which اینترنت است که خود « شبکه ای از رایانه های به itself is "a network of interconnected ، هم پیوسته» برای انتقال داده ها ( به عنوان مثال computers" to transfer data (for . اسناد وب و غیره) بین رایانه ها است،ایمیل example, emails, web documents etc.) between computers این تنها یکی از راه هایی است که می توان • • It is just one of the ways information . اطالعات را از طریق اینترنت به اشتراک گذاشت can be shared over the Internet. توسط سر تیم1989 شبکه جهانی وب در سال • • The World Wide Web was created in برنرز لی ایجاد شد 1989 by Sir Tim Berners-Lee این تنها یکی.وب زیر مجموعه ای از اینترنت است • • The Web is a subset of the Internet. It از راه هایی است که می توان اطالعات را از is just one of many ways information .طریق رایانه های شبکه منتقل کرد can be transferred over networked computers. How does WWW works? چگونه کار می کند؟WWW • The Web (World Wide Web) is a body of • وب (وب جهانی) مجموعه ای از اطالعات است که در information stored on web servers. . سرورهای وب ذخیره می شود • A web server can mean two things • یک وب سرور می تواند دو معنی داشته باشد • A computer on which a web site is hosted ای که یک وب سایت روی آن میزبانی می شود • • A program that runs on such a computer ای که روی چنین کامپیوتری اجرا می شود • • Term web server refers to both hardware and • اصطالح وب سرور به سخت افزار و نرم افزار اشاره software: : دارد • 1. The hardware web server computer کامپیوتر سرور وب سخت افزاری.1 • • A web site to be available to everyone in the world at all times, it need to be stored or "hosted" on a ، یک وبسایت برای اینکه همیشه در دسترس همه مردم دنیا باشد • computer that is connected to the internet. Such a »باید روی رایانهای که به اینترنت متصل است ذخیره یا «میزبان computer is known as a Web Server چنین رایانه ای به عنوان وب سرور شناخته می شود. شود • 2. The web server program • برنامه وب سرور • The software: Software that runs on the web site نرم افزاری که روی وب سایت میزبان کامپیوتر سرور:نرم افزار • hosting Server computer, Its main purpose is serving اجرا می شود و هدف اصلی آن سرویس دهی صفحات وب با web pages by retrieving web pages and giving it to بازیابی صفحات وب و ارائه آن به کاربران در صورت users as requested. .درخواست می باشد Software web servers وب سرورهای نرم افزاری • There are many server software اما دو،• گزینه های نرم افزار سرور زیادی وجود دارد options out there, but the two most :مورد از محبوب ترین آنها عبارتند از popular are: : ) (نرم افزار متن بازApache .1 • • 1. Apache(open source software) : برای رایانههای مبتنی بر یونیکس و روی مکهای دارای • • For Unix-based computers and comes . نصب میشودMac OS X سیستم عامل installed on Macs running Mac OS X. Microsoft Internet Information Services .2 • • 2. Microsoft Internet Information :( نسخه ویندوزIIS) Services (IIS) Windows version : بخشی از خانواده راه حل های سرور مایکروسافت • • Part of Microsofts family of server solutions What is browser? مرورگر چیست؟ • The web browser is software • مرورگر وب نرم افزاری است که به سرور وب می رود that goes to a web server to pull ) تا صفحه را از طریق شبکه به دستگاه شما (کالینت the page through the network, . بکشد to your machine(Client). • عامل کاربر • Also referred to as the user ) URI( • یک منبع اطالعاتی با یک شناسه منبع یکنواخت agent . شناسایی می شود • An information resource is identified by a Uniform Resource Identifier (URI). Client Vs. Server in web مشتری در مقابل • The words client سرور در وب and server have • کلمات کالینت و سرور two meaning : :دو معنی دارند • They can refer آنها می توانند به یک • either to a )کامپیوتر (سخت افزار computer یا یک برنامه (نرم ( hardware) or a .افزار) اشاره کنند program ( software) How does WWW work? Web Caches کش های وب • A mechanism for the temporary • مکانیزمی برای ذخیره موقت اسناد وب مانند صفحات storage of web document such as بار، برای کاهش استفاده از پهنای باند، و تصاویرHtml Html pages and images ,to reduce . سرور bandwidth usage ,server load. • مرورگر تمام درخواست ها را به حافظه پنهان ارسال می • Browser sends all request to :کند cache: اشیاء را برمی گرداندcache: در حافظه نهان باشدObject اگر • • If Object is in cache :cache returns سپس، شیء را از سرور مبدا درخواست می کندother cache • objects .شی را به مشتری برمی گرداند • else cache requests object from • کش هم به عنوان کالینت و هم به عنوان سرور عمل می کند origin server ,then returns object to client. نصب می شودISP • معموال کش توسط • Cache acts as both client and server • Typically cache is installed by ISP Web Cashe types انواع کش وب • There are two type of web cache: :دو نوع کش وب وجود دارد • • Browser cache: : کش مرورگر • • Is part of all popular web است که یک کپی محلی از تمام صفحات اخیرًا نمایش • browser that keeps a local copy داده شده را نگه می دارد و هنگامی که کاربر به یکی of all recently displayed pages نسخه محلی مجددًا،از آن صفحات باز می گردد and when user returns to one of .استفاده می شود those pages ,local copy is reused. : کش پروکسی • • Proxy cache: است که می تواند تراکنش وب را از طرف یک • • is shared network device that کش پروکسی،کالینت انجام دهد و مانند مرورگر can undertake web transaction .محتوا را ذخیره می کند on behalf of a client and like browser, proxy cache stores the content Proxy Cashe A bit about network کمی در مورد شبکه • Every computer and device (modem, router, گوشی، روتر،به هر رایانه و دستگاهی (مودم • smartphone, cars, etc.) connected to the اتومبیل و غیره ) متصل به اینترنت یک عدد،هوشمند Internet is assigned a unique numeric .منحصر به فرد اختصاص داده می شود • IP address (IP stands for Internet Protocol). .)Internet Protocol مخففIP( IP آدرس • • For example, the computer that hosts oreilly.com رایانه ای که میزبان،به عنوان مثال • oreilly.com has the IP address 208.201.239.100 . استIP 208.201.239.100 است دارای آدرس • All those numbers can be dizzying, so بنابراین،همه این اعداد می توانند گیج کننده باشند • fortunately, the Domain Name System (DNS) ) به گونه ایDNS( سیستم نام دامنه،خوشبختانه was developed to allow us to refer to that توسعه یافته است که به ما امکان می دهد به آن سرور server by its domain name . با نام دامنه آن اشاره کنیم • Ex. oreilly.com, facebook.com, mohe.gov.af ,.….. oreilly.com ، facebook.com، .سابق • ..…،mohe.gov.af • The numeric IP address is useful for computer عددی برای نرم افزارهای کامپیوتری مفیدIP • آدرس software, while the domain name is more در حالی که نام دامنه برای انسان قابل دسترس،است accessible to humans. .تر است URLs آدرس های صفحه وب و Web Page Addresses and URLs • Every page and resource on • هرصفحه وب آدرس خاص خود را روی وب دارد the Web has its own special Uniform Resource Locator به معنایURL که address called a URL Stands .است for Uniform Resource Locator. • این یک قرارداد نامگذاری استاندارد برای آدرس دهی اسناد قابل دسترسی از طریق اینترنت یا • It is a standardized naming .اینترانت است convention for addressing documents accessible over کامل به طور کلی از سه بخش تشکیل شدهURL • یک the Internet or Intranet. :است پروتکل.1 • A complete URL is generally نام سایت.2 made up of three parts: مسیر مطلق به سند یا منبع.3 1. The protocol 2. The site name 3. The absolute path to the document or resource HTTP Protocol HTTP پروتکل • Protocol is Set of rules or convention for • پروتکل مجموعه ای از قوانین یا قرارداد برای ارسال sending information, files and mails over a ) فایل ها و نامه ها از طریق شبکه (اینترنت،اطالعات network (INTERNET) .است • HTTP (Hyper Text Transfer Protocol) ) (پروتکل انتقال متن فوق العادهHTTP • • FTP (File Transfer Protocol) ) (پروتکل انتقال فایلFTP • • SMTP (Simple mail transfer protocol) ) (پروتکل ساده انتقال نامهSMTP • • … … • • HTTP? ؟HTTP • • Stands for Hyper Text Transfer Protocol استHyper Text Transfer Protocol مخفف • • Set of rules for transferring files (text, graphic images, sound, video, and other تصاویر،مجموعه قوانین برای انتقال فایل ها (متن • multimedia files) on the World Wide Web ) ویدئو و سایر فایل های چند رسانه ای، صدا،گرافیکی در شبکه جهانی وب • The language that web server and client (browsers) use to communicate is called زبانی که وب سرور و کالینت (مرورگرها) برای • HTTP. . نامیده می شودHTTP برقراری ارتباط استفاده می کنند HTTPS Protocol HTTPS پروتکل • Short for Hypertext Transfer Hypertext Transfer Protocol over • مخفف عبارت Protocol over Secure Secure • A secure method of accessing or • روشی امن برای دسترسی یا ارسال اطالعات در یک صفحه sending information across a web .وب page. قبل از ارسالHTTPS • تمام دادههای ارسال شده از طریق • All data sent over HTTPS is این امر مانع از آن میشود که هر کسی،رمزگذاری میشوند encrypted before it is sent, this . آن اطالعات را در صورت رهگیری درک کند prevents anyone from understanding that information if intercepted. URL : Site name نام:URL • www : : www • • This is a sub-domain prefix that is a اما،این یک پیشوند زیر دامنه است که یک قرارداد است • convention, but is not a rule.This portion of مورد نیاز نیست و میURL این بخش از.یک قاعده نیست the URL is not required and many times can .توان چندین بار از آن خارج شد be left out. : مثال. • • .example: .این یک زیر دامنه است • • This is a sub-domain. : کام. • • .com: این دامنه سطح باال است که به عنوان "پسوند دامنه " شناخته • • This is the top-level domain, is known as the می شود که برای شناسایی نوع یا مکان وب سایت مانند "domain suffix" used to identify the type or com. نمایش تجاری location of web site like .com show commercial URL : Absolute path مسیر مطلق:URL • The absolute path to the document or • مسیر مطلق به سند یا منبع resource • این مسیر مطلق از طریق دایرکتوری های روی سرور • This is the absolute path through . استfirst.html درخواست شدهHTML به سند directories on the server to the نام دایرکتوری ها،• کلماتی که با اسلش از هم جدا شده اند requested HTML document first.html. . هستند که با دایرکتوری ریشه میزبان شروع می شوند • The words separated by slashes are the directory names, starting with the root directory of the host. Anatomy of a Web page آناتومی یک صفحه وب • At the Figure, you saw a minimal web یک صفحه وب حداقلی را همانطور که در یک،• در شکل page as it appears in a graphical . مشاهده کردید،مرورگر گرافیکی ظاهر می شود browser. ،• اگرچه شما آن را به عنوان یک صفحه منسجم می بینید • Although you see it as one coherent : اما در واقع از چهار فایل مجزا جمع آوری شده است page, it is actually assembled from four HTML (index.html) یک سند • separate files: CSS (kitchen.css) یک شیوه نامه • • An HTML document (index.html) دو تصویر گرافیکی • • A CSS style sheet (kitchen.css) • Two graphic images. Lets do some practice!
!بیایید کمی تمرین کنیم
Putting It All Together همه اش را بگذار کنار هم • To wrap up our introduction to how the web works, lets اجازه می دهیم،• برای پایان دادن به مقدمه ما در مورد نحوه کار وب trace a typical stream of events that occurs with every web جریان معمولی از رویدادها را که با هر صفحه وب که روی صفحه page that appears on your screen: : ردیابی کنیم،نمایش شما ظاهر می شود رخ می دهد 1. You request a web page by either typing its URL in the آن در مرورگر درخواست میURL شما یک صفحه وب را با تایپ.1 browser. . کنید 2. Your browser sends an HTTP Request to the server named نامگذاری شدهURL به سروری که درHTTP شما یک درخواست.2 in the URL and asks for the specific file. . است ارسال می کند و فایل خاص را می خواهد 3. The server looks for the requested file and issues an HTTP صادرHTTP سرور به دنبال فایل درخواستی می گردد و یک پاسخ.3 response. . می کند 1. If the document is found, the server retrieves the requested file and returns it to the browser. سرور فایل درخواستی را بازیابی کرده و به مرورگر برمی،اگر سند پیدا شد .1 .گرداند 2. If the page cannot be found, the server returns an error message. The message typically says 404 Not Found پیام معموًال می. سرور یک پیغام خطا برمیگرداند،اگر صفحه پیدا نشد .2 یافت نشد404 گوید 4. The browser parses the HTML document. 1. If the page contains images ,the browser contacts the server . را تجزیه می کندHTML مرورگر سند .4 again to request each resource specified in the markup. The مرورگر دوباره با سرور تماس می گیرد تا،اگر صفحه حاوی تصاویر باشد .1 browser inserts each image in the document flow where مرورگر هر.هر منبع مشخص شده در نشانه گذاری را درخواست کند indicated by the img element. نشان داده شدهimg تصویر را در جریان سند درج می کند که توسط عنصر . است 5. The assembled web page is displayed for your viewing pleasure. .صفحه وب مونتاژ شده برای لذت مشاهده شما نمایش داده می شود .5