Search code examples
phpdatabasecachingmemcachedapc

php caching techniques


Hi this is more of an information request really.

I'm currently working on a pretty large event listing website and have started thinking about some caching for the data sets being used.

I have been messing with APC this week and have seen some real improvements during testing however what I'm struggling to get my head around is best practices and techniques required when trying to cache data that changes frequently.

Say for example the user hits the home page, this by default displays the latest 10 events happening and if that user is logged in those events are location specific. Is it possible to deploy some kind of caching system when dealing with logged in states and data that changes frequently, the system currently allows the user to "show more events: which is an ajax request to pull extra results from the db.

I haven't really found anything on this as I'm not sure what to search for but I'm really interested to know the techniques used for advanced caching systems that deal especially with data that changes and data specific to users?

I mean is it even worth it? are the other performance boosters when dealing with this sort of criteria?

Any articles or tips and info on this will be greatly appreciated!! Please let me know if any other info is required!!


Solution

  • Your basic solutions are:

    • file cache
    • memcached/redis
    • APC

    Each used for slightly different goal.

    File cache is usually something that you utilize when you can pre-render files or parts of them. It is used in templating solutions, partial views (mvc), css frameworks. That sort of stuff.

    Memcached and redis are both more or less equal, except redis is more of a noSQL oriented thing. They are used for distributed cache ( multiple servers , same cached data ) and for storing the sessions, if you have cluster of webservers.

    APC is good for two things: opcode cache and data cache. Faster then memcached, but works for each server separately.


    Bottom line is : in a huge project you will use all of them. Each for a different task.