WEB how does a cache system work?

Discussion in 'OT Technology' started by White Stormy, Aug 5, 2008.

  1. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    does it just build files and directories so that less content is actually dynamic..? and the server will be taxed far less?

    or does it just build .php files containing the CONTENT so that the server won't have to load that part and it'll be taxed a little less?

    or are there some that do both?
     
  2. andrey

    andrey New Member

    Joined:
    Aug 12, 2006
    Messages:
    931
    Likes Received:
    0
    I'm not an expert, but I've written cache systems in the past. Page content would be saved in static HTML files. Saving PHP files will create a security risk - especially if content comes from users.

    A cache system could potentially lift a lot of pressure off the database servers.
     
  3. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Joined:
    Sep 26, 2002
    Messages:
    2,396
    Likes Received:
    0
    Location:
    San Francisco, CA
    Caching is just storing already processed data. You can store these on the file system, but depending on the bottleneck in your system, you may not want to do that. For instance, you may want to cache results from a database to reduce the amount of disk I/O. In this case, you probably wouldn't want to store your cache on disk because it would still hit the disk to read the cache. OSes cache parts of the disk in memory that isn't used, but most of the time you want control over where your cache is stored and instead will want to store your cache directly in memory instead. A popular in-memory cache is memcached.
     
  4. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Joined:
    Sep 26, 2002
    Messages:
    2,396
    Likes Received:
    0
    Location:
    San Francisco, CA
    All user-submitted data should always be properly sanitized. But if you were caching for performance and wanted to save the cache to disk, it would be better to use HTML over PHP because of the overhead incurred of going through the interpreter. Though if you need some of the content to be dynamic, then you would use PHP.
     
  5. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
  6. TheDarkHorizon

    TheDarkHorizon \xC0\xFF\xEE

    Joined:
    Sep 26, 2002
    Messages:
    2,396
    Likes Received:
    0
    Location:
    San Francisco, CA
    The complexity of the query is more important than the number of queries, unless the number of queries isn't a constant number. Depending on the query, it would be faster to pull the cached data from the disk still. But it's still a better idea to use memory if you are looking to tweak performance and response times.
     

Share This Page