I would like to use the 'cache-control' or 'expires' headers for the static pages on my django app. (Ideally, I want to implement something equivalent to "expires max".)
How can I do that on opalstack? Thanks.
I would like to use the 'cache-control' or 'expires' headers for the static pages on my django app. (Ideally, I want to implement something equivalent to "expires max".)
How can I do that on opalstack? Thanks.
ngkabra custom options for static apps aren't available yet, but it's on our TODO list
Edit: done, for all apps!
Is this still a TODO? I would like to do the same. Google PageSpeed Insights lists this as a diagnostic issue on my pages.
stephenmwatts yep, still on the list but we hope to have it ready soon.
Can I set Cache TTL to images in a static app ?
I brought this up only because Page Insights recommended for improved page performance.
Is there any news on this? I'm also getting this suggestion from Page Insights.
Hey,
It's still on our list but not currently fixed. We'll make sure to post here when it is fixed.
This is a bit round-about, but I am having trouble on Google Search Console with Mobile Usability. My site passes their live test, but fails the crawl. When I check to see if they have clues, what I see is that Google isn't loading all of my resources. This appears to be the root cause of the mobility issues - at least that's what people on other forums think. I was thinking about using AWS for my static and media, and that perhaps that would fix the issue - but then my mind came back to THIS THREAD. I'm wondering if being able to set cache policy on my server for serving static files might help, because Google Experts on their forum report that the issue is that the Google Search Console crawl is running out of Crawl Budget - hence, this issue. I don't know for sure if this would fix it, but it seems possible. Status? Opinion?
stephenmwatts no progress on this yet, sorry.
If you'd like to test your theory:
I haven't done much work on setting up servers - spoiled first by Webfaction and now Opalstack. While I'm mulling that over, can you tell me what the default settings are for Cache Policy that our servers use?
I guess you are also saying "Well, it's possible."
stephenmwatts there are no default cache settings configured for any app types, including Nginx static-only apps.
In other apps it's possible to set them to whatever you need via the headers that your application returns, but this isn't possible for static apps.
We still plan to make some options available but for now the private stack is the best approach in my opinion. I'll update that procedure to include some examples for configuring the cache settings in the private Nginx config.
sean Thanks. I use Django. I've started looking over the suggestions you shared. Do you have anything directed toward this with a Django system, or should I just attempt to "translate" myself? The timing of the Mobilie Browsing Issues does seem to correlate with a significant hit to my traffic, so it's worth my time to see if this fixes the issue. I'd say they must've recently decided to more aggressively throttle their crawl budget - assuming, of course, that this is the problem.
stephenmwatts Django has a cache control decorator that you can use to set cache headers on views.
If you're using our uwsgi setup, then you can use addheader with uwsgi's internal routing feature to add whatever cache headers you need to whichever URL patterns.
sean Okay - that sounds more promising than me trying to figure out how to translate the instructions from PHP to Python. I'll dig in to that. Any links for configuring your uwsgi system settings or does that all just happen in uwsgi.ini?
What I think you are saying, though, is that I can use this to add cache headers for static (static and media) content. If not, please let me know. I do use cache for my other content.
stephenmwatts the django and uwsgi stuff wonโt cache anything served by your static apps. It will cache the content served by your django app.
Iโll have the Nginx examples done soon.
sean Thanks again. It likely won't be tonight, but I will dig into it and see if I can make it happen and, if I manage it I will be sure to provide feedback here. As you can tell, it likely won't be the last time you hear from me on the topic. :-/ I greatly appreciate your timely assistance!
To add some basic asset caching to a private Nginx stack, add the following within the location /
block of your nginx.conf:
location ~* \.(js|css|jpg|jpeg|png|gif|js|css|ico|woff|woff2|svg)$ {
expires 1y;
etag off;
if_modified_since off;
add_header Cache-Control "public, no-transform";
}
If you want to cache everything without regard to the content type, then don't wrap the config in its own location block eg:
expires 1y;
etag off;
if_modified_since off;
add_header Cache-Control "public, no-transform";
stephenmwatts Had the same issue on PHP Apache app, caching headers did not help at all. I resolved this by using CloudFlare's caching. Seemed like the server (Opal5) is too slow when serving a lot of static files.