Cakephp tmp directory: Cache and Session Folders

15,440

I'll try to describe their content (out of my head, so I may have missed some)

app/tmp/logs/

Contains various log files generated by CakePHP

app/tmp/sessions/

Contains the sessions of your website if 'Cake' is used as your session-handler if the php or database session-handlers are used, this directory will be empty. The session-handler can be configured in your app/Config/core.php configuration

app/tmp/cache/models

Will contain the model-cache; CakePHP will cache schema-definitions of your database tables, so that it's not needed to fetch that information from the database with each use.

app/tmp/cache/persistent

Will contain cache information about the location of classes/objects and parsed 'locale' files. This information will prevent CakePHP from having to scan all directories to find/load Controllers, Helpers etc.

The tmp/Cache directories may contain other files, for example if you're using 'view' caching, or other (custom) caching, this is the most probable location to store those cached information.

cache engines

The cache directories will only be used for the File cache mechanism. It's also possible to use other cache mechanisms, for example Apc or Memcached. These cache mechanism will keep the cached information inside the memory (RAM) of your server, which is a lot faster.

Read about cache engines in CakePHP here:

http://book.cakephp.org/2.0/en/core-libraries/caching.html

Share:
15,440
BIOS
Author by

BIOS

Updated on June 04, 2022

Comments

  • BIOS
    BIOS almost 2 years

    Can someone please explain to me what kind of data is stored in these directories?

    For example, I have an active session (with auth) now but the sessions directory is empty?

    What exactly is stored in the folders (models, persistent, views) within the cache folder?

    Ex in the persistent folder I have a file called 'myapp_cake_core_cake_dev_en-us' and if I open that I can see:

    1363808159
    a:1:{s:11:"LC_MESSAGES";a:0:{}}
    

    Please be as specific as possible.

    • summea
      summea about 11 years
      Cached copies of parts of your app.
    • BIOS
      BIOS about 11 years
      Really? As indicated in my question I am looking for specificity here. This is no way answers my question (there is a question about session folder there too). Additionally I can infer that the cache folder works as a cache. I want to know what its caching exactly (breaking down each folder) and how is the data stored (format) etc.
    • summea
      summea about 11 years
      What are you trying to do with this information?
    • BIOS
      BIOS about 11 years
      Better understand the framework? :?
    • summea
      summea about 11 years
      You may want to look into "serialization" in that case.
    • BIOS
      BIOS about 11 years
      That's a start. Thanks :)
  • BIOS
    BIOS about 11 years
    I'm using the 'Session' as a component. Is that what you mean by using cake as the session handler? If so, why would 'session' directory be empty with an active session? :?
  • thaJeztah
    thaJeztah about 11 years
    Inside app/Config/core.php there's a section 'Session configuration'. Inside this there's an explanation for various storage-methods (session-handlers) for the session; php, cake, database and cache. By default, this is set to php, which will store the sessions in the location set in php.ini (e.g. /tmp/)
  • BIOS
    BIOS about 11 years
    Excellent. Thanks for clarifying!
  • thaJeztah
    thaJeztah about 11 years
    Good luck with your project!
  • Hardik Gajjar
    Hardik Gajjar almost 7 years
    can i delete all files and folder under tmp ?
  • thaJeztah
    thaJeztah almost 7 years
    To be safe, you can remove the files, but keep the directories (at least the top-level ones. If I remember correctly, not all directories are created automatically, so removing them can result in errors.
  • Gegenwind
    Gegenwind about 5 years
    Old but gold: CakePHP (2.x) creates the cache folders only automatically if in debug mode. This can be especially probelmatic if a cache is not initialized at app startup so you might miss a folder without recognizing. To be save: Create the folders right away and dont delete them.