Jump to content

PHP Support

Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • Expertise
    PHP

PHP Support's Achievements

  1. An HTTP cookie (also known as a web cookie, Internet cookie, browser cookie, or simply cookie) is a small piece of data sent from a website and stored on the user’s computer by the user’s web browser while the user is browsing. Cookies were designed to be a reliable mechanism for websites to remember stateful information (such as items added in the shopping cart in an online store) or to record the user’s browsing activity (including clicking particular buttons, logging in, or recording which pages were visited in the past). They can also be used to remember arbitrary pieces of information. The information user previously entered into form fields such as names, addresses, passwords, and credit card numbers. Reason Behind using Cookie-Free Domains Cookies are very useful in some cases, in other cases – such as the delivery of static content, they can hinder performance. When a browser makes a request for a static asset such as an image or CSS file, there is no need for it to also send a cookie to the server. This only creates additional network traffic and since the files are static (they do not change) the server has no use for the added cookie. When you use cookie-free domains you are able to separate the content that doesn’t require cookies from the content that does. This helps improve your site’s performance by elimination unneeded network traffic. How to use Cookie-Free Domains? If you set your cookies on a top-level domain (e.g. yourwebsite.com) all of your sub-domains (e.g. static.yourwebsite.com) will also include the cookies that are set. Therefore, in this case, it is required that you use a separate domain name to deliver your static content if you want to use cookie-free domains. To reserve a cookieless domain for serving static content, you have to register a new domain name and configure your web server to serve static resources from the new domain, and do not allow any cookies to be set anywhere on this domain. If you set your cookies on a www subdomain such as www.yourwebsite.com, you can create another subdomain (e.g. static.yourwebsite.com) to host all of your static files which will no longer result in any cookies being sent. The following steps outline how to use cookie-free domains in WordPress: 1. Create a subdomain such as static.yourwebsite.com which is where you will deliver all your static files from. 2. Point your new subdomain to the /wp-content directory of your WordPress installation. For cPanel users, you will need to update the document root field from public_html/static to public_html/wp-content like the screenshot below. 3. Edit your wp-config.php file to reflect the following: <?php define(“WP_CONTENT_URL“,“http://static.yourwebsite.com“); define(“COOKIE_DOMAIN“,“www.yourwebsite.com“); ?> 4. Run the following command in your SQL database, this will ensure all post URLs are directed to the new subdomain: UPDATE wp_posts SET post_content = REPLACE(post_content,’www.yourwebsite.com/wp-content/’,’static.yourwebsite.com/’) Now that your cookie domain and static content subdomain are set. you can begin delivering static content without the server setting an unnecessary cookie for static assets.
  2. The first thing you can learn HTML, whether you want to become a professional web developer or just want to learn more about how websites work. The basic language for developing web pages and web applications is HTML. A server sends an HTML file to your computer every time you visit a website, and your browser interprets and displays the information contained in the file. What is HTML? HTML stands for Hyper Text Markup Language, which for many beginners is a confusing concept. The best way to understand HTML is to explain the meanings of each word. Hyper Text is a type of text that contains hyperlinks to other texts. Hypertext is used every time you click on a highlighted or underlined link that takes you to another page. A “web” of pages begins to form as more and more pages use hypertext to connect to one another. This is where the name “World Wide Web” comes from. Markup refers to the special symbols or codes inserted into a document to tell the web browser how to display the document data. Markup code, for example, will tell the browser to show a phrase in bold or italic text, or which sections of the document are headings and which are paragraphs. Markup code is used for a variety of languages, including HTML. Language refers to the concept of a standardised code. When writing HTML, everybody must obey those guidelines, much as when speaking a normal language. This is so that the code can be understood and interpreted by all browsers. There are numerous programming languages, and you may be familiar with some of the more common ones, such as Java, Python, and Ruby. HTML Tags You might remember that the use of angle brackets was the most prominent feature of HTML code. The angle brackets (and the code they contain) are known as tags. Tags are used to separate HTML code from standard text. The browser will not show any text written inside the angle brackets. The text inside the angle brackets is generally used to inform the browser about how to display or convert standard text between the opening (also known as the start) and closing tags (also called the end tag). Tags are usually found in pairs, and the difference between an opening tag and a closing tag is that a closing tag’s first symbol inside the brackets is a slash “/” symbol. For example, a pair of h1 tags (used to define heading text), with some content in between. <h1>content.</h1> In this example, the <h1> is the opening tag and the </h1> is the closing tag. How To Use Tags Here’s an example of how tags can be used to transform text. If we add the sentence “Some text.” to our HTML file, it will simply display as regular text, as shown below: Some text. If we want the sentence to be bold, we can use the <b> opening tag before the text and the </b> closing tag after the text. The letter “b” stands for “bold” in the tag. If we add <b>Some text.</b> to our HTML file, it will look like this: Some text. We may use an <i> opening tag before the text and </i> closing tag after the text to make the sentence appear in italic text. The “i” stands for “italic,” as you might have guessed. If we add <i>Some text.</i> to our HTML file, it will look like this: Some text. We can add an <a href=“www.google.com”> opening tag before the text and a </a> closing tag after the text if we want the sentence to be shown as a hyperlink. Can you figure out what the letter “a” stands for? This one is a bit more difficult… it stands for “anchor.” If we add <a href=“www.google.com”>Some text.</a> to our HTML file, it will look like this: Some text. This hyperlink will take us to a different webpage if we click on it. You can possibly guess which page this text links to if you look at the code. These three examples in to a simple HTML document: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <b>Some text.</b> <i>Some text.</i> <a href=”www.google.com”>Some text.</a> </body> </html> If you save this file and open it in a browser, it should look like this: Some text. Some text. Some text. Two Important Rules For Using Tags There are two main rules you need to follow when using tags. You must always use angle brackets for tags. In other programming languages, square and round brackets are used for other purposes. The browser will not understand your HTML code if you use square or round brackets. Tags almost always come in pairs. This means that you must always close a tag after opening it, except a few special examples. If you forget to add a closing tag the element you’re attempting to transform will not show properly. In the worst-case scenario, forgetting to close a tag could result in your page crashing.
×
×
  • Create New...