-
Notifications
You must be signed in to change notification settings - Fork 35
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
Thruster caches x-sendfile response and gives a 404 on subsequent requests if the file is removed (rails full page caching) #51
Comments
This problem is related to x-sendfile. I enabled debug, and this is the trace where the request gets cached for the first time:
Notice After the cache is expired on the rails side (
Disabling x-sendfile fixes the problem, at least in part (more on that below). What does Thruster cache for a x-sendfile response with a cachable header? It looks like its caching the wrong thing (not the file content, but the header to serve that file), causing it to need to go back to the Rails server to read the file again on every request, but not giving Rails a chance to recreate that file or change the response. Even with x-sendfile disabled the behavior is a little unexpected. When Rails answers /post, the default header returned specifies "no-cache/private". However once Rails does the full page caching the Static middleware serves the file, same as for assets. There is only a single configurable http header for this, so all static files get served with 1 year cache age. That can be worked around by adding some extra middleware in Rails. This is not a Thruster problem. I am only mentioning it in case someone comes across this in the future. |
Just notice #27 has reported something similar. |
I have a very old blog I am trying to bring up to Rails 8 with Thruster.
The app uses Rails full page caching, ie:
On the posts controller. What I have found is that on the first load of the posts index, everything works great - rails writes the cache file into public/posts/index.html. However I think Thruster then caches the static file on the next load.
Later, when I add a new post, the cache gets swept, removing posts.html from the public folder.
At this stage, if I navigate back to /posts, the rails action does not run as Thruster immediately returns a 404. So Thruster must check if the cached file it has on disk still exists before serving it, and if it is not there, it does not fall back to the Rails action. At this point it is stuck as there is no way to expire the cache and rebuild the index.
Is there any setting I might be missing to make this work out of the box, or some sort of "no cache" header I can set to tell Thruster to not cache this sort of asset?
The text was updated successfully, but these errors were encountered: