5 Replies - 7495 Views - Last Post: 03 September 2013 - 06:12 PM

#1 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 12
  • View blog
  • Posts: 816
  • Joined: 31-August 11

Is Caching Worth It?

Posted 09 August 2013 - 12:43 AM

So many times pages that load by taking information from a MYSQL database etc. etc. Many times I've heard some people say on here that using a cache isn't even worth it. What do you think?
Is This A Good Question/Topic? 0
  • +

Replies To: Is Caching Worth It?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4128
  • View blog
  • Posts: 13,023
  • Joined: 08-June 10

Re: Is Caching Worth It?

Posted 09 August 2013 - 01:04 AM

it depends on what you want to cache, the runtime of the uncached script (if the HTTP transfer time is bigger than the execution time, caching does not speed you up significantly), the RESTfulness of your application, etc.
Was This Post Helpful? 0
  • +
  • -

#3 BlueMelon  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: Is Caching Worth It?

Posted 09 August 2013 - 07:43 AM

Depends on many factors, and how much of your page needs new dynamic (un-cached) content every time it's loaded. For example, I have a blog. My blog is mostly static pages, I chose to cache them.

This post has been edited by BlueMelon: 09 August 2013 - 07:44 AM

Was This Post Helpful? 0
  • +
  • -

#4 VolcomMky  Icon User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: Is Caching Worth It?

Posted 10 August 2013 - 11:58 AM

As far as caching, I would have to agree with what the others are saying, it all depends on what you want to cache and how often content gets updated.

If your caching everything on a dynamic website, previous visitors would see old cached content while new visitors would see new content.

If you were to cache sub pages, that is something I would suggest.

Homepage, blog, dynamic content gets loaded that leads to the sub pages, so no, would not cache that
BUT the sub pages should be set and probably wont change, so I would cache them.

If you don't update your content much, I don't see a problem caching the entire thing and adding a feature to clear cache and rebuild :basecase:/>

And if your worried about comments being cached on blog pages, don't have them loaded when the page loads, I would suggest AJAX with disabled cache in the PHP Header() and possibly using jQuery's $.ajax(); with cache disabled

This post has been edited by VolcomMky: 10 August 2013 - 12:09 PM

Was This Post Helpful? 0
  • +
  • -

#5 Artaex  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 15-April 12

Re: Is Caching Worth It?

Posted 27 August 2013 - 05:49 AM

Hi,

I personally only use caching when loading information from external systems, such as remote APIs.
Especially when that API is located in another continent (latency issues).
But for local things, nope, not really.

~ Jeffrey
Was This Post Helpful? 0
  • +
  • -

#6 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: Is Caching Worth It?

Posted 03 September 2013 - 06:12 PM

As others have said, it depends on the application and how dynamic your content is. There are various forms of caching as well, it's not like you can just flick a on/off switch and everything gets cached - caching is broad concept that can be applied in many ways. Some search terms you might want to look into are:
  • .htaccess module mod_expires - A .htaccess module that allows you to set expiry dates on delivered content.
  • .htaccess module mod_deflate - A .htaccess module that sends content gzipped for faster delivery.
  • PHP memcache - A PHP module that allows you to persist variables on the server.
  • PHP APC - A PHP module that caches compiled PHP code.

There are also a lot of third party caching frameworks out there that allow you to cache generated content (i.e. - pages) and then subsequent calls to that page simply retrieve the cached file rather than generate the content from scratch again.

Caching is part of a broader concept of optimisation and streamlining, so some other topics you might want to look into are:
  • PDOs - If you are using the same queries over and over in the same session, this can result in faster DB round trips
  • DB Connection Pooling - Persistent connections to the DB that are stored in a pool drastically reduce your DB round trip time, as you don't need to establish a connection each time
  • DB Indexes - Indexing on DB tables can drastically improve performance of fetching data from the DB, especially if your queries involve many complex JOINs, or your tables contain many rows. Indexing reduces the performance of INSERTs and UPDATEs, but only by a small margin per index.
  • Image Compression - Make sure your images aren't overly huge, if so, compress them so they take less time to load
  • AJAX - Often it's not necessary to reload an entire page, just the parts that are due for update
  • Page Speed Google Developers - An excellent online resource that can poll a webpage and determine where optimisation opportunities lie
  • SSD servers - Solid state drives can drastically improve performance of a PHP application


This is by no means an exhaustive list, but it will give you a good starting point to looks into the various ways of improving site performance.

This post has been edited by e_i_pi: 03 September 2013 - 06:29 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1