Skip to content
Snippets Groups Projects
Verified Commit 15aee979 authored by David Beniamine's avatar David Beniamine
Browse files

Auto empty cache upon FS change and stack restart

parent b46f0545
No related branches found
No related tags found
No related merge requests found
...@@ -67,4 +67,3 @@ PicoZCache: ...@@ -67,4 +67,3 @@ PicoZCache:
dir: content/cache/html/ # Directory where cache should be saved dir: content/cache/html/ # Directory where cache should be saved
time: 2592000 # Interval between caching (period from one to second cache) in seconds, here is 7 days = 60 * 60 * 24 * 30. time: 2592000 # Interval between caching (period from one to second cache) in seconds, here is 7 days = 60 * 60 * 24 * 30.
xhtml_output: false # If true, XHTML Content-Type header will be sent when loading cache page xhtml_output: false # If true, XHTML Content-Type header will be sent when loading cache page
ignore_url_regex: "/blog/"
...@@ -5,7 +5,7 @@ RUN composer create-project --no-interaction picocms/pico-composer pico ...@@ -5,7 +5,7 @@ RUN composer create-project --no-interaction picocms/pico-composer pico
FROM php:7.4-apache FROM php:7.4-apache
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y libonig-dev libxml2-dev locales && \ apt-get install -y inotify-tools libonig-dev libxml2-dev locales && \
docker-php-ext-install -j$(nproc) dom mbstring && \ docker-php-ext-install -j$(nproc) dom mbstring && \
docker-php-ext-enable dom mbstring docker-php-ext-enable dom mbstring
...@@ -19,3 +19,9 @@ COPY --from=builder /app/pico /var/www/html ...@@ -19,3 +19,9 @@ COPY --from=builder /app/pico /var/www/html
RUN a2enmod rewrite RUN a2enmod rewrite
COPY pico.conf /etc/apache2/sites-enabled/000-default.conf COPY pico.conf /etc/apache2/sites-enabled/000-default.conf
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh
#!/bin/bash
basedir=/var/www/html
cachedir=$basedir/content/cache
clear_cache() {
echo "Clearing HTML cache"
rm -rf $cachedir/html/*
echo "Clearing TWIG cache"
rm -rf $cachedir/twig/*
}
watcher() {
clear_cache
inotifywait -m -r -e modify -e move -e create -e delete \
--exclude '\.*.sw?' \
--exclude $cachedir \
$basedir |\
while read dir ev file; do
echo "File $ev detected"
clear_cache
done
}
watcher &
exec apache2ctl -DFOREGROUND
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment