.css if edited shows old version even if deleted and reuploaded with the same name categorized

So far i quite like hestia but there is one issue im facing that is making me crazy. Static website html css when i edit my css in file manager and or delete and upload the new version cannot be seen in the browser. I have no cache that i know of nginx on port 80 and 443 non interactive install. cache disabled on 2 different browsers, cache disabled in cloudflare ctrl f5 flushed sudo rm -rf /var/cache/nginx/*
systemctl restarted nginx I really cant think of much else I could do. If i rename the file to a new name like add 1 number likes styles.css : styles2.css the change will be reflected as long as I rename it in html (naturally) but if i change the name of that new file back to the name of the old file styles.css the change will be unreflected. Now clearly this must be caching somewhere and it cant JUST be caching the name as a new file named the same as an old file with a different date cant be the same or an old version. Ive tried different devices different os’s to make sure its not a client cache and it always serves the old version so somewhere in my setup there is a cache that must be killed.

You should create a new template for your domain, modify a location block and assign that template to your site.

The templates for Nginx standalone are located here /usr/local/hestia/data/templates/web/nginx/php-fpm/. If you are using Nginx+Apache, the templates for Nginx are here /usr/local/hestia/data/templates/web/nginx/

Note: In this example I’m using the Nginx standalone.

/usr/local/hestia/data/templates/web/nginx/php-fpm/default.tpl has this section:

location / {
                location ~* ^.+\.(jpeg|jpg|png|webp|gif|bmp|ico|svg|css|js)$ {
                        expires max;
                        fastcgi_hide_header "Set-Cookie";
                }

And you must modify it like this:

        location / {
                location ~* ^.+\.(jpeg|jpg|png|webp|gif|bmp|ico|svg|css|js)$ {
                        open_file_cache off;
                        proxy_cache off;
                        proxy_no_cache 1;
                        proxy_cache_bypass 1;
                        add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
                        expires off;
                        add_header Pragma "no-cache";
                        etag off;
                        fastcgi_hide_header "Set-Cookie";
                }

Let’s say your user is pxop, the domain is example.net and the new template will be newtemplate :stuck_out_tongue:

cd /usr/local/hestia/data/templates/web/nginx/php-fpm
cp default.tpl newtemplate.tpl
cp default.stpl newtemplate.stpl

Next, edit newtemplate.tpl and newtemplate.stpl, and modify the location directive location ~* ^.+\.(jpeg|jpg|png|webp|gif|bmp|ico|svg|css|js)$ { so that it matches the example provided above.

Once both files have been modified, add the new template to your domain:

v-change-web-domain-tpl pxop example.net newtemplate yes

Now, any changes to your CSS will be reflected instantly, with no caching at all.

1 Like

In my above post, I made wrong assumption that the problem arises from building assets.Hence, I deleted my solution. Reading your post fully, I have one more idea.

If you are using the Cloudflare, or a similar CDN provider, they have caching system. Then this can happen that the old file is in their cache and after renaming to style2.css the new file will be instantly served.

If this is the case, you will have to turn off their cache or empty it or setup the domain to development mode to reflect the changes immediately.

1 Like

After beating the server to absolute death and looking on cloudflare for a long time I did find the caching issue on cloudflare even turning of caching didn’t work I had to make 2 rules and limit cache in browser times. Because even Ctrl f5 wouldn’t clear css fully caching was very agressive for some reason.

After making one rule with every caching option full off

And one rule with cache times being zero and putting cache times 0 in nginx I finally got no caching if I clear the cache.

However sometimes…..I still have to clear the cache with a manual purge cloudflare has lots of good features but I feel like they need to relax on the caching lol. That was very intense.