Comments (10)
We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/110687262.
from staticfile-buildpack.
@mastertinner Thanks for putting an issue in. The team will discuss your proposal this week. In the interim, please feel free to use nginx.conf
in the root folder as you wish.
from staticfile-buildpack.
@Dannyzen, thanks for letting me know. I am using a custom nginx.conf
but I think it's something that would make sense to put into default nginx.conf
. I'm looking forward to hearing about your decision.
from staticfile-buildpack.
Worth noting that I believe adding this feature for all applications will cause trouble for apps staged with <1M of memory. Let's please investigate that before considering this PR.
It might be more interesting to consider using the application memory quota to imply an appropriate caching limit (if we can access this information at application startup time).
from staticfile-buildpack.
Hi @mastertinner when you say greatly improve performance what change metrics can you share that support this claim?
from staticfile-buildpack.
@Dannyzen, I can't say that in general because it depends on the site size and structure of the respective application. What I can say is that caching makes sense for apps which consist of only static files because then the client doesn't have to download the same content every time it visits the app, which can make the app a lot faster from a client's perspective and use less resources for nginx. I stumbled upon the issue when I was testing my apps hosted by this buildpack with Google Pagespeed and Pingdom Website Speed Test which both advise to use caching for static content.
Thanks for your input, @flavorjones! Maybe it would make sense to make this an opt-in feature through ENV
variables like the FORCE_HTTPS
feature:
<% if ENV["CACHING_EXPIRY"] %>
location ~* \.(jpe?g|png|gif|ico|svg|css|js|eot|ttf|woff|woff2)$ {
expires <%= ENV["CACHING_EXPIRY"] %>;
}
<% end %>
or
<% if ENV["ENABLE_CACHING"] %>
location ~* \.(jpe?g|png|gif|ico|svg|css|js|eot|ttf|woff|woff2)$ {
expires 1M;
}
<% end %>
from staticfile-buildpack.
@mastertinner I need more help understanding exactly what you're hoping to get out of enabling caching withing nginx. I've found that nginx reading static files from disk is pretty fast with out-of-the-box nginx options. Without some benchmarks that show compelling improvements in performance, I would likely vote against adding this to the buildpack.
Now, if you're talking about enabling cache-control headers for use by a CDN, that's something I can definitely get behind, but that's not what the nginx option you're suggesting deals with.
Finally, keep in mind that you're free to use whatever nginx config you choose by providing an nginx.conf file. See the readme for more information.
from staticfile-buildpack.
@flavorjones, my concern is not about reading files from disk but rather about the second point you mentioned: setting the right headers to allow a visitor's browser to cache static files so that it doesn't need to download them every time the user visits the site. In my point of view this is important not only for CDNs but for any static website/web app. I think the term I'm trying to explain is referred to as "Leverage Browser Caching": https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
from staticfile-buildpack.
@mastertinner Got it! Just to reiterate, the option you suggested above does not control cache headers, but @Dannyzen will be able to talk a bit about cache control headers, as we have another github issue talking about this that I can't find right now.
from staticfile-buildpack.
@mastertinner I'm hesitant to include the optimizations mentioned in this issue without data to prove positive impact. Additionally, the expires 1M;
could yield unfavorable results in certain scenarios. With that said, @flavorjones mentioned #59 which we would like to explore more with your help.
from staticfile-buildpack.
Related Issues (20)
- [Test Issue]
- problems behind a revers-proxy chain with multivalue x-forwarded-host and x-forwarded-prefix HOT 6
- How to provide application context path while deploying through staticfile build pack HOT 2
- Erroneous warning that nginx 1.21.x will no longer be supported in new buildpacks after 2022-05-25 HOT 2
- Release: staticfile-buildpack (Feb) HOT 1
- [QUESTION] When will staticfile-buildpack be available on cflinuxs4 stack? HOT 2
- Missing mime type for otf files (opentype fonts) ? HOT 5
- Release: staticfile-buildpack (Mar) HOT 1
- Ruby is not available in cflinuxfs4 HOT 1
- Release: staticfile-buildpack (Apr) HOT 1
- Release: staticfile-buildpack (May) HOT 1
- Release: staticfile-buildpack (Jun) HOT 1
- Release: staticfile-buildpack (Jul) HOT 1
- Release: staticfile-buildpack (Aug)
- Release: staticfile-buildpack (Sep) HOT 1
- Release: staticfile-buildpack (Oct) HOT 1
- Release: staticfile-buildpack (Nov) HOT 1
- Release: staticfile-buildpack (Dec) HOT 1
- Release: staticfile-buildpack (Jan) HOT 1
- Release: staticfile-buildpack (Feb) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from staticfile-buildpack.