example for caching cloud function for firebase requests and only re cache after a successful edit to the profile

本秂侑毒 提交于 2020-01-13 19:24:10

问题


In my app, Users profiles are open to the public and only updated by the profile owner.

The profile URL is example.com/profile?user=@user.me

And based on the docs https://firebase.google.com/docs/hosting/functions. I can cache the response JSON of the function, in this case, the public profile. Which will save me a lot of at cloud functions executions and Firebase database bandwidth

And when the user updates his profile, I want to re cache the profile in the CDN.

I think that can be done by making the user re-request his public profile, with Cache-Control: no-cache in the request header, after a successful update of his profile.

And when a user visits that same profile afterward he shall see the new version.

Is that possible ?? or that's not how Cache-Control shall be used.


回答1:


firebaser here

The integration between Cloud Functions, Firebase Hosting and its CDN is currently a purely time-to-live based cache. When you set a cache-header in your Cloud Functions, the CDN puts your response in its edge caches for the time period you indicate. Once it expires, the CDN edges will stop serving the content from the cache and request a fresh copy from the server when a user on that edge requests it.

We know that having an API to tell the CDN to refresh this content would allow for many additional use-cases. But this is currently not in the scope of Firebase Hosting.



来源:https://stackoverflow.com/questions/45255232/example-for-caching-cloud-function-for-firebase-requests-and-only-re-cache-after

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!