Server spin down revert deleted media files structure

System Information

I’m hosting Starpi CMS with free Render web app tier.

  • Strapi Version: v4.25.4
  • Node Version: v20.15.1
  • Deployment env: Render free tier

observed similar issues

3 years ago similar issue was spotted, and the conclusion was cache is not being emptied properly, and you had a thought then that you should add feature to manually clean it, it’s not done yet or I cannot find it? But anyways as described below, I recreated all app but with old name and old file structure persist so or even cache after project delete is not cleaned or I somehow deliver this broken structure.

Plugins

module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: "cloudinary",
      providerOptions: {
        cloud_name: env("CLOUDINARY_NAME"),
        api_key: env("CLOUDINARY_KEY"),
        api_secret: env("CLOUDINARY_SECRET"),
      },
      actionOptions: {
        upload: {},
        delete: {},
      },
    },
  },
});

Middleware

export default [
  "strapi::logger",
  "strapi::errors",
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": ["'self'", "data:", "blob:", "res.cloudinary.com"],
          "media-src": ["'self'", "data:", "blob:", "res.cloudinary.com"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  "strapi::cors",
  "strapi::poweredBy",
  "strapi::query",
  "strapi::body",
  "strapi::session",
  "strapi::favicon",
  "strapi::public",
];

Issue description
In the moment of deleting all media and uploading again, they are linking to Cloudinary and everything is okay. Also on local environment. However on deployment with render.com, after a server spin-down and when it runs again, it has already deleted files with links to uploads, which breaks my front-end app. What I tried to do was completely delete and set up a new web app, but the problem persists. I am using the free Render tier with spin-downs and no SSH, because the configuration was instant and Azure DevOps is overwhelming for me. I know the obvious solution is to take paid basic no spin down tier but for some time I need this site on instant it will work and after I will stop paying this will be broken again so I need to figure out why is it reverting this state. Obvious answer seem to be cache related issues but ain’t re creating app-service from scratch up should solve this? When I look for any name of those files on my local cms app i cannot find any match so in local files I push to git there are non old upload media files.

Steps to Reproduce:

  1. Upload media files in Strapi CMS.

  2. Server spins down and restarts (using free tier Render service).

  3. Media files are no longer accessible, and links point to deleted files.

Attempts to Fix:

• Deleted all files and re-uploaded.

• Set up a new web app.

• Problem persists with each server restart.

Environment:

• Free Render tier with server spin-downs.

Request:

Looking for advice on how to maintain media file integrity after server spin-downs and restarts.


Hi there,

Uploaded files will not persist on a Render service without adding a disk (or a database). Our docs have all the details: https://docs.render.com/disks

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

Hello
that’s not the point. I know they will not persist and that’s not the problem cause I have used external CDN network, as mentioned above. Problem is that after spin downs I’m getting some already deleted files with it’s not persisting structure which should be overwritten but after each spin down the old state of those comes back.

Hi there,

Any changes whatsoever to the files or directory structure within a running Render service will revert back to state they were in when copied from the connected repository upon each restart/deploy. A service restart happens after each spin-up from idle.

If you wish to persist changes to any files within the service, those changes will need to be saved to a persistent external source, e.g. a disk, a database, a Redis instance, or changed within the branch getting deployed.

Regards,
Mike


Render Support Engineer, MT (UTC-6, UTC-7 in Winter)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.