JREAM
JREAM

Hi,

First off thank you for such an amazing platform to use. I am still getting use to it and enjoying it immensely. I have one question regarding caching during development. I am aware of the following to clear cache:

./artisan cache:clear

However, it seems I have to run this frequently to see changes which is inconvenient. A hack would to write a shell script like this:

cache.sh (chmod +x)

#!/bin/bash
while true; do
  php artisan cache:clear
  sleep 2:  # Re-run every two seconds, or until this is cancelled out
done

Another possible way (I am unsure of) is to use array caching possibly, rather than files.

config/cache.php

'default' => 'array',

This will obviously do nothing:

<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">

Lastly, another idea I had was to set opcache off and even run the artisan command from the PHP script. I prefer the .env setup, so I tried mocking this up but I'm not sure where I should place it..

Final Attempt

./.env

DISABLE_CACHE=true

./.htaccess (Apache)

php_flag opcache.enable Off

Or FastCGI

./.user

opcache.enable=0

Or

ini_set('opcache.enable', 0);

I couldn't find the best solution nor know how you develop with the cache constantly rebuilding the front-end, any advice would be greatly appreciated. Im sorry if this has been covered in the docs or a forum I was not able to find it.

Tschallacka
Tschallacka

In your opcache settings in the php.ini on your development machine set the revalidation to 10 seconds

  opcache.revalidate_freq=10

Then set checking timestamps to true

   opcache.validate_timestamps=1

This way opcache will check if the cached version is older than 10 seconds if the file has changed. if so it updates the cached version.

on your development machine, go to your october install directory.

in october/config/cms.php set parsedPageCacheTTL to 1 minute.

  'parsedPageCacheTTL' => 1,

Also, october "should" update the pages if the template files have been updated.

Also, in your browser open the console and disable caching there(on chrome press f12, click on network and check disable cache)

1-2 of 2