I am curious would a file based cache be just as fast as a file based session handler in PHP?
+2
A:
I suppose a couple of differences could come from these points :
- file-based cache, contraty to session-based one, could be shared by several used
- session are not necessarily stored in files (you could use a database, memcached, ... )
- sessions are read automatically by PHP each time you are calling session_start(), and written back to disk at the end of the script -- which can be more often than if you are dealing with the cache's files yourself, reading/writting them only when necessary
- Data written to / read from session are serialized -- for files, if you are writting only string, there is no need to serialize (and you are the only one who can know if serialization is needed or not)
- you can delete a file from cache easily -- you cannot delete data from the session of another user than the current one
Another things :
- Sessions are generally used to store small pieces of data
- Sessions should be used to store only data specific to one used
Pascal MARTIN
2010-01-19 05:18:09