3. kafli vefforritun

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

relative vs absolute URL

An absolute URL starts with the protocol, while a relative URL can start with a /, a folder name, or a file name. A relative URL always refers to a resource located on the same server as the resource (HTML file) containing the URL, relative from the location of that particular resource. You should therefore watch out for the following link: <a href="www.example.com">click me</a> which is NOT the same as: <a href="http://www.example.com">click me</a> i.e. the former example does not point to the server at http://www.example.com/, instead it points to a file located in the same folder as the file containing this link! This is usually not what you would want.

MIME types

As stated above, when the web server returns a document to the browser (með http respond), it will also specify the MIME type of the document. The browser will use the MIME type to decide how to display the document: as a text file, as an image, as a video etc. The browser cannot rely on file extensions for this purpose, mostly because there may be no such extension (the request/response may not include a particular extension), and a web service (with a given extension) may return an image file in one case but a text file in another.  There are a number of common MIME types you should recognize: ● text/html As noted above, this is usually the MIME type served with HTML files. ● text/css Used when serving CSS files. ● image/jpeg, image/png Used when serving images.

Cache

Browsers will generally try to store the results of requests in their cache, since it is highly likely that a given request will be repeated by the user, and there is high probability that the response would be the same. Hver browser hefur sitt eigið cache. Cache geymir líka cookies sem eru skrárnar sem eru sendar með http request og response

Cookies

Cookies are small text files which may be sent along with requests and responses. They are then stored in the browser cache, and can contain whatever values the web server chooses. As stated above, they are one of few mechanisms used to maintain state between sessions. They are also a potential security threat more on that later, once we start discussing security issues in web applications.

http

HTTP is the protocol mostly used on the internet for communication between a browser and a web server.

typical http response

HTTP/1.1 200 OK ● HTTP Status code This is the first line of the response. See below for a list of status code categories. Date: Thu, 13 Jan 2011 01:08:39 GMT Server: Apache/2 ● Server The server includes what web server software is running the server Apache in this case. ContentLocation: Home.html Vary: negotiate,accept TCN: choice LastModified: Wed, 12 Jan 2011 18:30:28 GMT ETag: "671a499aa65305900;893f26bd17a2f00" AcceptRanges: bytes ContentLength: 26394 ● ContentLength The length of the content, in bytes. CacheControl: maxage=600 Expires: Thu, 13 Jan 2011 01:18:39 GMT ● Expires This value indicates when the content should be removed from the browser cache (more on that below). P3P: policyref="http://www.w3.org/2001/05/P3P/p3p.xml" Connection: close ContentType: text/html; charset=utf8 ● ContentType This represents the MIME type of the response. Different file types use different MIME types. For instance, HTML files will usually be served using the "text/html" MIME type, while .jpg files will be served using the "image/jpeg" MIME type. More on this below.

SEO

Passa upp á leitarvélar og þar með accessability fyrir fatlaða (sjóndaprir nota leitarvélar mikið). ● Ensure that the keywords you want your users to find your website by, are located in the following places: ○ The title of the website ○ The <h1> heading ○ The URL ○ The META tags inside the <head> section (even though Google doesn't use the keyword meta tag) ○ In the content, preferably very early in the content ● Make sure the main content of your page is located as close to the top of the file as possible. This is important since some SE spiders will stop reading a page when it exceeds a certain file size. ● Ensure your URLs are well formed, and that they contain a minimal amount of query string variables. Example: the following URL: http://www.example.com/EditStudent.aspx?ID=27 would be better like this: http://www.example.com/Student/Edit/27 since search engines could ignore query string parameters (especially if there are many parameters) Önnur leið til þess að auka leitarvélarbestun er ef það eru margar síður sem linka á þína síðu. Black hat misnotar þetta. Verður að passa líka upp á heading structure svo leitarvélar geti leitað á síðunni.

HTTP methods

Til 9 aðgerðir en við notum aðallega GET og POST. Eru flestar idempotent (aðgerðir sem í raun breyta engu t.d. að margfalda tölu með 1). Venjulegir linkar eru alltaf GET. POST aðgerðir breyta einhverju t.d. skrifa í gagnagrunn, senda pöntun o.s.frv. T.d. getur from notað bæði get og post en post er aðeins notað ef fyrir data input. Non-idempotent

Any order columns

Til þess að síðan okkar hafi sem besta leitarvélarbestun er best að hafa main content html-ið sem fyrst en við getum svo breytt staðsetningunni með css.

rendering engine

blandar saman HTML og CSS og skilar á skjáinn

status codes

er efst í http request ● 1xx Informational status codes These status codes are actually not used very much. ● 2xx Success status codes The most common one is probably 200 (OK), which the web server will return if there are no problems. ● 3xx Redirection status codes These status codes tell the browser that additional action must be taken. Usually this means that the browser should issue another request to a particular URL specified in the response. The most common one is 302 (Redirect). ● 4xx Client error When the web server replies with a 4xx response code, it means that there was a problem with the request. By far the most common status code returned from this category is 404 (Not found), which is returned if the client issues a request for a page that doesn't exist. ● 5xx Server error These status codes are returned when an error occurs on the server, and which prevent the request from being completed.

web server

server sem hýsir vefsíðuna. Apache er algengasti með 41%

CSS Sprite

setur allar myndirnar á síðu í einn file þannig það þarf bara eitt http request og það tekur líka minna pláss.

web requests

web requests are stateless; i.e. once the server has returned its response, it has forgotten all about it. The next request sent from the very same browser is seen as a completely new request with no connections whatsoever to the previous request. It is however possible to circumvent this slightly by using HTTP cookies (covered below), but the stateless architecture of the web should always be kept in mind.

http request

það sem gerist þegar notandi slær enter á slóð í vafra

http response

það sem vafrinn sendir aftur til clientsins (sjá 55)

http://[email protected]:8080/ folder/file.html?key=value &anotherKey=someValue#fragmentID

●http The protocol used to send the request for this particular resource. Most of the time this will be either http or https (see the list of protocols above). This is also called a scheme. ●: This is what separates the protocol from the actual URL ● // Some protocols (such as http and https) may require the location to start with a double forward slash. However, TimBerners Lee has said that in hindsight, he probably should have left this out of the specification, since it serves no real purpose. ● user If the resource requires authentication, the username of the user requesting the resource may be located before the name of the server. The @ symbol separates the username from the servername. ● www.example.com This is the name of the server. Note that there is no requirement that the name starts with a "www", and this could also be the IP address of the server. ● 8080 In this case, the URL specifies what port to use to connect to the resource. If omitted, the default port for this particular protocol will be used. In case of http, the default port number is 80. ● folder The resource requested could be located in a subfolder on the server, and the URL could reflect that. Do note however that there is no requirement that the "folder structure" of the URL maps to an actual folder structure on any particular machine (see later about URLs in ASP.NET MVC). ● file.html The name of the file requested. It is perfectly possible that there is no such file name in the URL, particularly if the URL isn't pointing to a specific file, but instead pointing to a resource or a service. Also, web servers usually define a "default" file for a particular folder that will be served if no filename is present in the request. The name of this file is often index.html, but this can be specified in the web server. This is why requests for URLs such as http://www.example.com/ are served properly, since the web server will serve the default document in that case. ●? The question marks indicates the start of the query string. The query string is appended to the actual location, and identifies additional parameters which are passed along with the request. ● key=value This is the first value which is a part of the query string. It comes in the form of a key/value pair, i.e. you can look this value up by name. Note that the equal sign is used to separate the key from the value. ●& The ampersand is used as a separator between query string values. ●# The hash symbol separates the actual URL from a token which specifies a particular location within the document you will be taken to (specified by fragmentID). ● fragmentID As briefly mentioned in chapter 1, the fragmentID refers to a particular location within the file or resource being requested. Inside an HTML file, it can be specified by using <a name="fragmentID" />, or by giving a heading tag an id attribute with "fragmentID" as the value (see the discussion about the anchor tag in chapter 1). As you have noticed, there are certain characters that have special meaning in URLs, such as ?, &, =, and others, and can therefore not appear in querystrings or in the fragment id. So if you are writing code that creates a URL, you would usually have to beware of this (more on this later). Also, you should not create URLs that contain spaces (use the + character instead).


संबंधित स्टडी सेट्स

econ 4.2 - nominal v. real interest rates

View Set

Chapter 23: Cells and Tissues of the Plant Body

View Set

fahmy 100 ( bible ) arabic & french 14

View Set

Ch 8: Florida Statutes the surplus lines law

View Set