Broken assets when deploying to production

I wasn’t able to find this particular issue anywhere else, but sorry if this is a duplicate of another thread.

My setup: Sage 9-based theme with Bedrock, deploying with Deployer on a Dreamhost VPS.

The problem: CSS and JS work fine using start, build or build:production on my local environment, but the links to them are broken on production.

The hashed JS and CSS files are on the production site in dist, but the links in the theme are pointing to outdated versions of the hashed files, resulting in 404s. As part of the deploy process, I build locally, remove the remote dist folder, sync the local build of dist, remove the remote blade cache folder in uploads and flush permalinks.

However, after about 10 minutes or so, the links update and everything works again. So the CSS and JS assets are fine, and it seems like a caching issue with how Sage links to those assets.

I’m just trying to narrow down the problem – is there something I’m missing in my deploy process, or is it more likely to be a caching issue on the server?

Thanks for any help anyone could provide.

Not sure whether this helps, but when deploying a bedrock site (with sage theme) using Trellis,
some extra steps are done for finalizing the deployment, like clearing transients:

Maybe some of these steps have to be replicated when using the Deployer tools you mentioned,
so the cache invalidates immediately?

Thanks, @strarsis, I look into those and see if any of those steps help.

I’m starting to think I’m just hitting the OPcache on the server, which is why the PHP function calls to the asset URLs are returning an old value, while static assets are updated and correct. After a few minutes, the asset URL functions start returning the updated filenames, so the cache seems to be clearing after a certain amount of time.

This topic was automatically closed after 42 days. New replies are no longer allowed.