Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate delay when adding assets #367

Open
ddeboer opened this issue Feb 27, 2018 · 6 comments
Open

Investigate delay when adding assets #367

ddeboer opened this issue Feb 27, 2018 · 6 comments

Comments

@ddeboer
Copy link
Contributor

ddeboer commented Feb 27, 2018

When building versioned assets (containing a unique hash in their filename), it takes quite a while for Zotonic to pick up the change. This is the case on both on our (Docker) development environment and (native) production ones.

inotify picks up the change quickly, but still the file returns a 404:

lager:set_loglevel(lager_console_backend, debug).

Then execute npm run build:

zotonic_1        | 12:07:15.181 [debug] [filewatcher] create of "/opt/zotonic/user/sites/abc/lib/elm/dist/style-9fc59629.css"
  1. Is the problem related to Docker? Docker has some trouble synchronising large amount of files efficiently between the host and the Docker containers.
  2. Does the problem occur as well when simply adding a static file (bla.txt), so without the NPM build step?
  3. Does a z:flush() make the files available immediately?

/cc @rl-king

@ddeboer
Copy link
Contributor Author

ddeboer commented Mar 12, 2018

  1. Not related to Docker, as it happens on our non-Docker servers as well.

@rl-king
Copy link
Contributor

rl-king commented Mar 12, 2018

  1. Yes
  2. No

@ddeboer
Copy link
Contributor Author

ddeboer commented Mar 13, 2018

Does it make a difference if you have mod_development enabled?

@mworrell
Copy link
Contributor

mworrell commented May 24, 2018

Checking if I am correct in understanding the issue.

  1. Add a new file
  2. inotify does its work
  3. Load the file in the browser via /lib/new/file/path.css

Then step (3) doesn't show the file and returns 404?

Did you try loading the file before step 2?
In that case we might have a file handler which is caching the 404.

@mworrell
Copy link
Contributor

I just tried:

Lamma:lib marc$ echo `date` > t1.css; curl -I 'http://test.dev:8000/lib/t1.css'
HTTP/1.1 404 Object Not Found
Vary: Accept
Server: MochiWeb/1.1 WebZMachine/2.0 (Z) Zotonic/0.39.0
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Expires: Wed, 10 Dec 2008 14:30:00 GMT
Date: Thu, 24 May 2018 08:04:24 GMT
Content-Type: text/css; charset=utf-8
Content-Length: 26
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Lamma:lib marc$ curl -I 'http://test.dev:8000/lib/t1.css'
HTTP/1.1 200 OK
Server: MochiWeb/1.1 WebZMachine/2.0 (Z) Zotonic/0.39.0
Last-Modified: Thu, 24 May 2018 08:04:24 GMT
Expires: Fri, 24 May 2019 08:04:38 GMT
Date: Thu, 24 May 2018 08:04:38 GMT
Content-Type: text/css; charset=utf-8
Content-Length: 30
Cache-Control: public, max-age=31536000
Access-Control-Allow-Origin: *

So requesting the new file will serve it.
What might be an issue is that the file is picked up by re-indexing, if this re-indexing is slow then it will take some time before the file is known to the system.

Iff this is the root cause of the mentioned problem then we could add the file directly to the index of all sites that have enabled the affected module. This is possible iff the file is a new file, as otherwise we need to take the module hierarchy in account (which is done by the indexer).

@mworrell
Copy link
Contributor

On a side note, the Zotonic lib tag is generating hashes based on the modification dates of files. Maybe you can use this tag? Then you also don't need to clean up old files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants