Hello I want to put "One Year" of cache on all files, except ìndex.html that I want Cache-Control: no-cache
But I get :
I expect the last line to override the default_expiration but i get :
cache-control: no-cache
cache-control: public, max-age=31536000
my app.yaml
runtime: nodejs12
default_expiration: '365d'
env_variables:
environment: '--prod'
handlers:
- url: /
static_files: myproject/index.html
upload: myproject/index.html
http_headers:
Cache-Control: no-cache
On the index.html.... both at the same time do you have an idea how to have only the first header ?
This is actually an expected behavior at the moment.
1) If you set default_expiration: 0 and Cache-Control: no-cache is set in the http_headers of the handlers then the following headers will be set:
cache-control: no-cache, must-revalidate
expires: Fri, 01 Jan 1990 00:00:00 GMT
2) If default_expiration is the default (10m), or a particular value is set as in your Case, '365d' and you override expiration on per-handler basis, then handlers with expiration: 0 will be served also with 10m or the value set caching. So, the output you got is actually the expected output at the moment.
I agree that 2) may be unexpected and this same concern has been raised with the App Engine team on this thread and on this issue link. It is not considered a bug at the moment, but an internal feature request was submitted to the App Engine team for necessary modifications. I suggest you bookmark the issue link for updates on the fixes as there is no ETA for the implementation at this time.
Related
I followed the official configure-spring-boot-starter-java-app-with-azure-active-directory tutorial but I can't seem to get it to work. I've confirmed the redirect url is exactly as written with the same security controller.
Here is my request headers:
HTTP/1.1 302
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: https://login.microsoftonline.com/07d020b6-d78f-40cb-b6c7-98eab8c29a94/oauth2/v2.0/authorize?response_type=code&client_id=8ff48ac1-1ddf-479d-ac5a-5db407c70c50&scope=openid%20profile%20https://graph.microsoft.com/User.Read%20https://graph.microsoft.com/Directory.Read.All&state=aUtWlcsG6Oc6NnYxA8z7E339CVlfodi7kBs5HiNIx8M%3D&redirect_uri=http://localhost:8080/login/oauth2/code/&nonce=xhjQJa-IVP_9kXFKsDX_oNrLprt4HnqDzUgyYqrjyBA
Content-Length: 0
Date: Fri, 16 Apr 2021 17:31:11 GMT
Keep-Alive: timeout=60
Connection: keep-alive
Note that the location contains my RedirectURI: http://localhost:8080/login/oauth2/code/azure
I've also reviewed other issues, and it feels close but, as mentioned, the tutorial what was provided -- so it should work.
Please let me know if you need any other information.
Request Id: a6cb6d0d-9a3a-4bd3-a2b7-c16c053c7b01
Correlation Id: 9f74d074-df2c-4a73-8c79-31aa7442a427
Timestamp: 2021-04-16T16:54:36Z
Message: AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application: '8ff48ac1-1ddf-479d-ac5a-5db407c70c50'.
You actually sent
http://localhost:8080/login/oauth2/code/
as redirect_uri in logon request. But app was likely defined with following redirect_uri.
http://localhost:8080/login/oauth2/code/azure
They don't match. Hence the error.
I did a quick check to see make sure my site was 301 redirecting from:
https://inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite
to the www. version:
https://www.inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite
However, when I checked, I found that there was an extra 301 redirect happening from the www. url to:
/news/iceye-shows-off-new-sharp-images-from-satellite
without the domain name anywhere to be found. Here is the full log of that second redirect:
>>> https://www.inlunar.com/news/iceye-shows-off-new-sharp-images-from-satellite
> --------------------------------------------
> 301 Moved Permanently
> --------------------------------------------
Status: 301 Moved Permanently
Code: 301
Cache-Control: public, max-age=0, must-revalidate
Content-Type: text/html; charset=UTF-8
Date: Wed, 17 Jun 2020 01:09:17 GMT
Etag: "8af6153ff17d129285674adb734ca0e3-ssl"
Strict-Transport-Security: max-age=31536000
Age: 0
Server: Netlify
X-NF-Request-ID: 69351fad-bde6-4674-a9b8-fe017a45ee0c-2118676
Location: /news/iceye-shows-off-new-sharp-images-from-satellite/
Why is this second 301 redirect happening?
Netlify appears to be redirecting to the location of the current request with a trailing slash, consistent with their documentation, in an effort to improve cache hit rates.
As for the omission of the domain, it's simply a relative URL.
Relative URLs are URLs that do not include a scheme or a host. In
order to be understood they must be combined with the URL of the
original request.
Client request for http://www.example.com/blog:
GET /blog HTTP/1.1
Host: www.example.com
Server response:
HTTP/1.1 302 Found
Location: /articles/
The URL of the location is expanded by the client to
http://www.example.com/articles/.
EDIT: I have fixed the problem - see my answer below
I have an app (flyxc.app) that has been deployed for a few months without any issues.
I tried to deploy the app again yesterday and get errors:
Uncaught SyntaxError: Invalid or unexpected token from parsing my js.
This is because the JS looks like:
[q*u�Md�m��0�yw������N�綥4q
rG7��yt�i���#UU�1�.P�\���~�Z��n>N�H'Y0L�t�s������㞰*�
�T&�i��>�-o���T�1���'`�7uǀ�v��!/z}���aC����C�<���}����"� XԼ�g�ӳ�rl-ZU���-Z��*)rA�u�8v*�>l��>!���mHCu�6��Vt��8H� tH��?
jC_����W7_e��7'��z��8R��u�t~)����w\�ƭ�"*�}���ľ�O�b~U����f��+w8rS0$]f��U�˲�2To5.�Gb;�_����~m�z�f
...
By looking at the size of the JS, it seems that it is gzip encoded however the response headers do not contain the content-encoding header:
alt-svc: h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
cache-control: max-age=0
content-length: 72212
content-type: application/javascript; charset=utf-8
date: Sun, 31 May 2020 15:11:57 GMT
last-modified: Tue, 01 Jan 1980 00:00:01 GMT
server: Google Frontend
status: 200
vary: Accept-Encoding
x-cloud-trace-context: c0f4c28a3d84fdb29a8d7caf0d1bbf83;o=1
I did install the ModHeader chrome extension to remove the accept-encoding header from the request.
Removing the header force the server not zip the response and give the expected payload:
function e(e,t,i,o){var r,s=arguments.length,n=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n}function t(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}const i=new WeakMap,o=e=>(...t)=>{const o=e(...t);return i.set(o,!0),o},r=e=>"function"==typeof e&&i.has(e),s="undefined"!=typeof window&&null!=window.customElements&&void 0!==window...
The JS is served directly by the servers. Here is my app.yml:
runtime: nodejs12
instance_class: F1
automatic_scaling:
max_concurrent_requests: 80
target_cpu_utilization: 0.9
handlers:
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
Because there seems to be no way to control this header on the app engine side, I suspect a problem on the app engine side.
Could someone help ?
I have fixed the problem.
The JS was actually served by a Koa JS server.
The Koa server used to compress the JS.
In the end the JS was double gzipped.
I have removed the compression in the Koa server and now everything works fine.
Note: I still do not exactly understand why I worked for 6 months before starting to fail on May 31 - the compression is the Koa server has been here for the last 6 months.
I have a plan to change the hosting of my angularJS static app from a S3 bucket to a GCS bucket. But I have some problems with the metadata of the html template files.
I have copied the files with the command gsutil and I have already set all files in the bucket with the public_read permission. Now I can access the index.html file and serve it with text/html content-type, but the template file metadata has been changed by google storage to application/xml and, when accessing it, the status code is 401.
Status Code: 401 Unauthorized
Cache-Control: private, max-age=0
Content-Length: 131
Content-Type: application/xml; charset=UTF-8
Date: Thu, 24 May 2018 03:44:21 GMT
Expires: Thu, 24 May 2018 03:44:21 GMT
Server: UploadServer
WWW-Authenticate: Bearer realm="https://accounts.google.com/"
Sometime it works and sometime it doesn't. What can I do in this situation?
There has been this new video on youtube demonstrating the strength of EdgeCaching in the GAE architecture, and at this particular point in the video they demonstrate how easy it is to leverage:
http://www.youtube.com/watch?v=QJp6hmASstQ#t=11m12
Unfortunately it's not that easy...
I'm looking to enable edge caching using the webapp2 framework provided by Google.
I'm calling:
self.response.pragma = 'Public'
self.response.cache_expires(300)
but it seems overridden by something else.
The header I get is:
HTTP/1.1 200 OK
Pragma: Public
Cache-Control: max-age=300, no-cache
Expires: Sat, 23 Feb 2013 19:15:11 GMT
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
X-AppEngine-Estimated-CPM-US-Dollars: $0.000085
X-AppEngine-Resource-Usage: ms=39 cpu_ms=64
Date: Sat, 23 Feb 2013 19:10:11 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Vary: Accept-Encoding
Server: Google Frontend
Content-Length: 600
I'm using ndb top level:
app = ndb.toplevel(webapp2.WSGIApplication(...
I tried the technics explained here, but they don't seem to apply to webapp2:
http://code.google.com/p/googleappengine/issues/detail?id=2258#c14
I also looked at this post too:
https://groups.google.com/d/topic/webapp2/NmHXoZZSVvo/discussion
I tried to set everything manually with no success. Something is overriding my cache settings.
Is there a way to make it work with webapp2? Any other option is welcome.
EDIT: I'm using an url with version prefix: http://version.appname.appspot.com and it's probably the cause of my problem.
This should be all you need:
self.response.cache_control = 'public'
self.response.cache_control.max_age = 300
Check Caching Details for more information, may be you broke some rules. Next the best part:
A response can be stored in Cloud CDN caches only if all of the following are true:
It was served by a backend service with caching enabled.
It was a response to a GET request.
The status code was 200, 203, 300, 301, 302, 307, or 410.
It has a Cache-Control: public directive.
It has a Cache-Control: s-maxage, Cache-Control: max-age, or Expires
header.
It has either a Content-Length header or a Transfer-Encoding header.
Additionally, there are checks that will block caching of responses. A response will not be cached if any of the following are true:
It has a Set-Cookie header.
Its body exceeds 4 MB.
It has a Vary header with a value other than Accept, Accept-Encoding, or - Origin.
It has a Cache-Control: no-store, no-cache, or private directive.
The corresponding request had a Cache-Control: no-store directive.
I'm guessing that you're mixing up two related but distinct ideas.
The first idea, which the video you link to talks about, is arranging to have certain files in your app served by a pool of App Engine servers that specialize in serving static content. This is faster than having your app serve these files, since there won't be a delay to start up a new instance of your app to serve a static file. (Strongly consider serving up your .js and .css this way.) This static serving facility is controlled entirely at app update (upload) time, via declarations you make in app.yaml (or appengine-web.xml for Java apps).
The second idea is arranging, via HTTP response headers, for pages that your app emits to be cacheable by caches outside of app engine.
If you declare files as static, you have some control over addition HTTP response headers that get served along with the file. See the documentation on configuring static files.