SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question General questions about development techniques

    Hi,

    I'd like to ask a few quick questions about some development techniques. If you can at least point me to the right direction in your answers, I'd really appreciate that:

    1. Why do so many sites place their resource files (javascript,css, images..etc) in a different domain?

    2. I've noticed a plenty of sites include their CSS/Javascript files this way:
    Code:
    <link rel="stylesheet" type="text/css" href="/generated/stylesheet.css?1233155929" />
    why are these files "generated" (as the name implies)? and what's up with the numbers at the end?

    3. When installing an update for your application that requires changes in different components (db tables, classes..etc), do you have to take down the whole site temporarily, or is there a way to install the updates without affecting the users' experience?

    4. How do you avoid caching issues for your application's resources when you update them, without disabling caching? (if that's possible)

    5. When you perform major changes in your application (how data is formatted/stored or whatever else), do you write something to batch process and upgrade all of your current users' data? or is there a different approach to this?


    Your input is much appreciated

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mPeror View Post
    2. I've noticed a plenty of sites include their CSS/Javascript files this way:
    Code:
    <link rel="stylesheet" type="text/css" href="/generated/stylesheet.css?1233155929" />
    why are these files "generated" (as the name implies)? and what's up with the numbers at the end?
    To ensure browser's use the latest updated version of a css or javascript file. It avoids potential problems that may arise from browser caching.

    Quote Originally Posted by mPeror View Post
    3. When installing an update for your application that requires changes in different components (db tables, classes..etc), do you have to take down the whole site temporarily, or is there a way to install the updates without affecting the users' experience?
    You don't have to, though it's generally wise to.

    Quote Originally Posted by mPeror View Post
    4. How do you avoid caching issues for your application's resources when you update them, without disabling caching? (if that's possible)
    #2

    Quote Originally Posted by mPeror View Post
    5. When you perform major changes in your application (how data is formatted/stored or whatever else), do you write something to batch process and upgrade all of your current users' data? or is there a different approach to this?
    Yes and no. Generally, most people will use some sort of revision managment software -- for instance subversion -- that allows you to pull the latest revision from it's storage. From there it's simply a matter of checking out the latest version, cleaning it and ftp-ing it, or moving it if the repository is stored within the network, to the application root.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. performance. browsers load only N (~8 IIRC) resources at
    once from one domain. or maybe its from an CDN.

    2. prevent problems with cached resources. i wonder why people use timestamps, a revision number is much better. they're generated because
    people like to compress css and js.

    3. i'd take the server down, the cost for an transparent solution is too high.

    5. should not happen. really, it depends what those changes are, but most
    of the time you'll think about how to avoid it.

  4. #4
    SitePoint Guru
    Join Date
    Jun 2006
    Posts
    638
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mPeror View Post
    1. Why do so many sites place their resource files (javascript,css, images..etc) in a different domain?
    That is usually the media server.
    - It doesn't have to parse code, so it can serve more files than your main web server.

    Quote Originally Posted by mPeror View Post
    2. I've noticed a plenty of sites include their CSS/Javascript files this way:
    Code:
    <link rel="stylesheet" type="text/css" href="/generated/stylesheet.css?1233155929" />
    why are these files "generated" (as the name implies)? and what's up with the numbers at the end?
    That's to break the cache. Usually the browser cache, but can also break the "server" cache (proxies and so on that can cache data for you).
    It's better to have a revision number there rather than the timestamp (so you cache the data, and after you update, it re-cached automatically)

    Quote Originally Posted by mPeror View Post
    3. When installing an update for your application that requires changes in different components (db tables, classes..etc), do you have to take down the whole site temporarily, or is there a way to install the updates without affecting the users' experience?
    Depends, taking down the site is easier, but if you pay for advertising and so on, you end up losing money while the site is down.

    Quote Originally Posted by mPeror View Post
    4. How do you avoid caching issues for your application's resources when you update them, without disabling caching? (if that's possible)
    Same as browser caching (I assume your talking about server cache, as in APC/MemcacheD and so on).
    Easiest way would be to prefix your cache keys with a revision number. (and after each update, it's like clearing your cache... so you might want to do it in a smart selective way)

    Quote Originally Posted by mPeror View Post
    5. When you perform major changes in your application (how data is formatted/stored or whatever else), do you write something to batch process and upgrade all of your current users' data? or is there a different approach to this?
    Depends on the time it takes. If changing the data to the new system takes 4 hours, it's better to make a script to do it slowly while your site is up. It might take lets say a week, but users will never know. Once the db data is migrated to the new format/system, you put your code changes up, pointing them to the new tables.
    Note: you will have to deal with (port over) the updates that happened in that "week".

    Hope that helps.

  5. #5
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    imaginethis, elias and Vali: thank you very mcu hguys

    I have two follow up questions if you don't mind though:

    1. Do the resources files need to be in a different server in order for them to load faster, or would putting them in a different domain on the same server do the job?

    2. Do I have to type the revision numbers after the CS/JS files by hand every time I update them, or is there an automatic way to do so?

  6. #6
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mPeror View Post
    1. Do the resources files need to be in a different server in order for them to load faster, or would putting them in a different domain on the same server do the job?
    Are the domains on the same server? If so then they are accessing then they are exhausting the same system's resources.

    Quote Originally Posted by mPeror View Post
    2. Do I have to type the revision numbers after the CS/JS files by hand every time I update them, or is there an automatic way to do so?
    Do you have to? No you can automate it if you'd like.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  7. #7
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mPeror View Post
    1. Do the resources files need to be in a different server in order for them to load faster, or would putting them in a different domain on the same server do the job?
    Different domain (or subdomain) on the same server, will allow the browser to open more connections, thus improving load time.

    Quote Originally Posted by mPeror View Post
    2. Do I have to type the revision numbers after the CS/JS files by hand every time I update them, or is there an automatic way to do so?
    For larger projects, people usually have a deploy script. This will make a checkout from the repository and put it on the production server. You can hook a script in to this process that replaces a place holder with the current revision number.

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken View Post
    Different domain (or subdomain) on the same server, will allow the browser to open more connections, thus improving load time.
    Does that mean loading all CSS files/images from the same domain will do so over the same HTTP connection? Interesting.

  9. #9
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SJH View Post
    Does that mean loading all CSS files/images from the same domain will do so over the same HTTP connection? Interesting.
    Yes, the browser will only open so many connections to the same domain at a time (I don't remember the exact number, but 8 is probably a good guess). It will gladly open more connections if they are on different domains. That's why all images etc. on this forum are served from sitepointstatic.com

  10. #10
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    The browser will by default open eight parallel connections if the connection is HTTP/1.0 but if its HTTP/1.1 it will by default only use two parallel connections (Both is per host name).

    So using more hostnames is a good idea if you want so speed up the downloading of the webpage. Just keep in mind that every hostname you use also adds an overhead (dns request etc) so dont use too many.

    While we are on the topic, move the javascript includes to the bottom of the html code as when the browsers download a javascript script it blocks all other downloads until its finished. And as always remember cookies are the devil, so avoid to use them for anything else than what is required (session id etc).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •