Resarting AppEngine after a file is modified - google-app-engine

Whenever I make a change to my html file, I have to resart appengine server to see the change reflected. Why is this so? In Flask for example the server automatically reloads whenever it detects a file change. Can this be done in AppEngine?

That's not the normal behavior for local development. You should be able to update your html files, as your code, without the need to restart the server.
Can you tell us more about your setup? Might there be a caching mechanism in your code that doesn't check the filesystem to refresh appropriately?

Related

Force updates on installed PWA when changing index.html (prevent caching)

I am building a react app, which consists in a Single Page Application, hosted on Amazon S3.
Sometimes, I deploy a change to the back-end and to the front-end at the same time, and I need all the browser sessions to start running the new version, or at least those whose sessions start after the last front-end deploy.
What happens is that many of my users still running the old front-end version on their phones for weeks, which is not compatible with the new version of the back-end anymore, but some of them get the updates by the time they start the next session.
As I use Webpack to build the app, it generates bundles with hashes in their names, while the index.html file, which defines the bundles that should be used, is uploaded with the following cache-control property: "no-cache, no-store, must-revalidate". The service worker file has the same cache policy.
The idea is that the user's browser can cache everything, execpt for the first files they need. The plan was good, but I'm replacing the index.html file with a newer version and my users are not refetching this file when they restart the app.
Is there a definitive guide or a way to workaround that problem?
I also know that a PWA should work offline, so it has to have the ability to cache to reuse, but this idea doesn't help me to perform a massive and instantaneous update as well, right?
What are the best options I have to do it?
You've got the basic idea correct. Why your index.html is not updated is a tough question to answer to since you're not providing any code – please include your Service Worker code. Keep in mind that depending on the logic implemented in the Service Worker, it doesn't necessarily honor the HTTP caching headers and will cache everything including the index.html file, as it seems now is happening.
In order to have the app work also in offline mode, you would probably want to use a network-first SW strategy. Using network-first the browser tries to load files from the web but if it doesn't succeed it falls back to the latest cached version of the particular file it tried to get. Another option would be to choose what is called a stale-while-revalidate strategy. That first gives the user the old file (which is super fast) and then updates the file in the background. There are other strategies as well, I suggest you read through the documentation of the most widely used SW library Workbox (https://developers.google.com/web/tools/workbox/modules/workbox-strategies).
One thing to keep in mind:
In all other strategies except "skip SW and go to the network", you cannot really ensure the user gets the latest version of the index.html. It is not possible. If the SW gives something back from the cache, it could be an old version and that's that. In these situations what is usually done is a notification to the user that a new version of the app has been donwloaded in the background. Basically user would load the app, see the version that was available in the cache, and SW would then check for updates. If an update was found (there was a new index.html and, because of that, new service-worker.js), the user would see a notification telling that the page should be refreshed. You can also trigger the SW to check for an update from the server manually from your own JS code if you want. In that situation, too, you would show a notification to the user.
Does this help you?

if make i changes in cpanel filemanager it doesn't really take effects on the web site

so as you see from the address I make changes in the public_html folder and I see the changes through the cpanel filemanager. however, it doesn't make any changes in the website and when I try to see the files of the website through my domain Ienter image description here can see that there are no changes happened . the changes is like creating a new folder or file or even renaming a file
This type of problems may occur due to server sided caching or it can be a simple bug which doesn't let the code to execute it on the website.
Or might be the server issues, for which you should contact the customer care of your hosting provider.
Try to clean cache of your browser and also disable the caching in your server if enabled.
Try these all things and you may see changes.

How to pass deployment settings to application?

I am trying to deploy a Qooxdoo web application backed by CherryPy-hosted web services onto a server. However, I need to configure the client-side Qooxdoo application with the hostname of the server on which the application resides so that that the Ajax callbacks resolve to the right host. I have a feeling I can use the capabilities of the generate.py Qooxdoo script to generate client-side code with this appropriately set, but reading through the docs hasn't helped make it clear how yet. Anyone have any tips?
(FWIW, I know how I'd approach this using something like PHP and a different client-side framework like Echo 3--I'd have the index file be a PHP file that reads a local system configuration file prior to sending back client-side code. In this case, however, the generate.py file is a necessary part of the toolchain, so I can't see how to do it so simply.)
You can use qx.core.Enviroment class to add/get configuration for your project. The recommend way is only during compilation time, but there is a hack if you want to configure your application during run time.
Configuration during compilation time
If you want to configure the environment during compilation time see this.
In both cases after you add any environmental variable to your application, it can be accessed using the qx.core.Environment.get method.
On run time
WARNING this method isn't supported/documented from qooxdoo. Basically it's a hack
If you want to make available some environment configuration on run time you have to do this before qooxdoo loads. In order to this you could add some javascript into your webpage e.g.
window.qx = { };
window.qx.$$environment = {
"myawsomeapp.hostname": "example.org",
};
This should be added somewhere in your page before the qooxdoo start loading otherwise it will not have the desirable effect. The advantage of this method is that you can push configuration to the client e.g. some api keys that may be different between instances of your application.
The easiest way will be to compose your AJAX URL on the fly from window.location; ideally, you would be able to use window.location.origin which for this StackOverflow website would be "https://stackoverflow.com" but there are issues with that on IE.
A cross platform solution is:
var urlRoot = window.location.protocol + "//" +
window.location.hostname + (window.location.port ? ':' +
window.location.port: '');
This means your URL will always be correct, even if the server name changes (eg your on a test server instead of production).
See here for more details:
https://tosbourn.com/a-fix-for-window-location-origin-in-internet-explorer/

Use a remotely rendered page instead of /public/index.html

I wonder if its possible to insteady relying on the source code of the file stored in /public/index.html one can use a remotely generated page to be used as the template for the dev server of create-react-app.
The point is that I'd like to take a page that contains data that is generated by the server and have my react app running in there for development purpose.
As far as I understand, the webpack dev server loads the file from the HDD upon request, modifies the content and delivers it to the browser. So technically it shouldnt be a problem to retrieve the source from a remote URL instead of the local hard drive, right?

force default version of google appengine to update on deployment

I have a Java based web application running on google appengine that depends on data in the datastore. When I update this backend data and deploy. I can see the data change immediately if I access the url 1-dot-myapp.appspot.com. I cannot get the default version of the url (myapp.appspot.com) to update on another device unless I access the full specific version of the url.
How can I force the default version of the application to update on deployment?
Thank you
I went back and looked at my cookies information. 1-dot-myapp.appspot.com only has a _ga cookie, the entry for myapp.appspot.com has 3 cookie values: application cache, ACID, and _ga. I was surprised that 1-dot-myapp.appspot.com did not have an application cache value in the cookie. So now I guess my question is. How can I force the application cache to renew as desired.
What I came up with was to either remove reference to my manifest file from my html or to rename my manifest file. So when ever I want to for the client browser to update the cache I redploy with a newly named manifest file. The manifst file is renamed with a version number like manifest2.mf. Then my build modifies all references for manifest to the newly name manifest file i.e. manifest2.mf. My html files and my appengine.xml file then us manifest2.mf . these changes seem to force the client browsers to update their cache.

Resources