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

Serve static assets with an efficient cache policy #1154

Closed
barredterra opened this issue Apr 16, 2021 · 3 comments
Closed

Serve static assets with an efficient cache policy #1154

barredterra opened this issue Apr 16, 2021 · 3 comments

Comments

@barredterra
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Google PageSpeed Insight complains that static files served by frappe don't have a caching policy. For example, I'm serving a slideshow on a frappe-based website. The images will be loaded again and again, every time I visit the site.

Describe the solution you'd like

Serve static assets with an efficient cache policy.

Probably we can add some lines here to attach a cache policy to images served.

location / {
rewrite ^(.+)/$ $1 permanent;
rewrite ^(.+)/index\.html$ $1 permanent;
rewrite ^(.+)\.html$ $1 permanent;
location ~ ^/files/.*.(htm|html|svg|xml) {
add_header Content-disposition "attachment";
try_files /{{ site_name }}/public/$uri @webserver;
}
try_files /{{ site_name }}/public/$uri @webserver;
}

@ankush
Copy link
Member

ankush commented Jun 20, 2022

For example, I'm serving a slideshow on a frappe-based website. The images will be loaded again and again, every time I visit the site.

I don't think this is true as even without cache-control headers browsers will still cache things heuristically. 👀 Open the network tab and check. They'd most likely be loaded from disk. Please confirm if that's not happening ( much worse scenario)

@ankush ankush self-assigned this Jun 20, 2022
@barredterra
Copy link
Collaborator Author

barredterra commented Jun 20, 2022

@ankush I can confirm that Chrome automatically caches files for the short term (i.e., hitting reload does not download the files again). But I expect this cache is short term and will not survive a browser restart, etc. This issue is in regard to long term caching (say, a couple of months or until the content changes).

@ankush ankush removed their assignment Oct 31, 2022
@ankush ankush closed this as completed in 8d3270e Jan 17, 2024
@ankush
Copy link
Member

ankush commented Jan 17, 2024

image

1.5 mil request with response, 0.5mil more with 304 on FC. EVERYDAY! 🤣

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

No branches or pull requests

2 participants