I am working on ASP.NET MVC4 Project. When i am updating JavaScript file and run my project in browsers. New changes do not reflected on page Same thing happen when I am trying on IIS Server. For that every time I have to remove browser history then it reflects but this is not correct way after deployment
Is there any other way for that?
Please guide me Thanks in advance
Your problem would be:
Browser Caching JavaScript
Check whether the browser is caching the javascript. To do it, check the header of the javascript on the browser for the attribute Cache-Control in the browser. Case yes, configure Cache-Control to no-cache on the project. Disable cache only in your development environment.
Visual Studio or IIS not reloading the javascripts
Check whether the Visual Studio or IIS are reloading your entire project after the deploy.
Suggestions to solve your problem:
Solutions to solve this problem is version the javascript.
Using different names
One way to ensure that the user will receive a fresh version of javascript is versioning the filename.
Instead of use only the name, you can concatenate a version number to the javascript.
Example:
www.example.com/script.8238823.js
www.example.com/script.3434342.js
This urls represent different paths and the browser will update.
Using query string
Another way is use a query string such v= + version.
The version can be a MD5 hash, or the timestamps or the size in bytes of the file.
Example:
www.example.com/script.js?v=999990
www.example.com/script.js?v=129
This force the browser to cache the file, and reload when the version of v, change.
I don't use ASP.NET, but I think that exists solutions for this.
I saw similar answers here which I think would help you. Specifically, the suggestion of adding a query parameter to the end of the URL which references your JavaScript file, so you can "version" them.
Not sure if this is the same problem. For my ASP.NET MVC4 project I had an Azure database and web app. The reason the javascript file was not updating was because the connection to the database had lapsed. Refreshing in Server Explorer solved the issue / reestablishing the connection with a new login fixed the issue.
Also make sure the way you are publishing has the correct database admin login and connection.
Are you using the MVC Bundle? By using bundle and js inclusion as #Scripts.Render("file name used in the bundle config file") should not sustain cache.
Related
So, I'm making a quiz, and I've been wanting to save my answers to a text file. I want to use "Node.js", and I'm worried about this: They only offer an installer to install Node.js on your computer. Since I'm not working with servers or anything like that, and I'm just a hobbyist, the people I might first give this to may not have Node.js installed on their computer. Please do note that this is for a website, not a program.
Is this kind of thing possible to do without the use of a hosting service or a server? :
const lib = require('./libraries/NODE')
If it is, how would I do it?
Thanks for any help!
There are two options for you:
I would suggest using something like Electron- which will wrap the node runtime for you - https://www.electronjs.org/docs/tutorial/first-app which you can distribute to people. This will open up all the nodejs related functionality and more for you.
Another answer at SO though old, suggests using window.name vs writing out text files - Javascript/HTML Storage Options Under File Protocol (file://)
You cannot import nodejs runtime into the browser running on a file protocol.
I'm currently working on a user interface for an Eclipse & IntelliJ plugin which should work within a SWT Browser instance. Therefore everything has to be written in HTML and JavaScript, but has to work locally.
I wanted to try out Angular 2, but it seems to be a very big problem, that I won't have my files hosted on a server, because of all the internally used XHR requests. Is there any way I could trick it into working without having to deliver a local server (which would be kind of a overkill)?
Thanks in advance for any ideas!
I develop an angular-php web application which I have it running online, for different users, on 5 different subdomains, such us:
sub1.mydomain.com
sub2.mydomain.com
sub3.mydomain.com
sub4.mydomain.com
sub5.mydomain.com
Problem:
My problem is that I still develop the web-app local and whenever I change files(php, js,tpl.html,css or when add new ones) I have to upload them on each subdomain.
Question:
Is there a way/library/API whatever that I can use to make something like package (with the updated or new files) and just call it from each subdomain url , and make the appropriate updates?
Or should I just copy them to each subdomain?
Do I make myself clear, in other words just like on cms systems that we press the update button and we update a component/module.
If anyone knows a way of doing that please enlight me. Thanks.
I tried to depict what i mean.
What you are describing is called deployment.
There are a lot of ways to create a deployment mechanism so there is not a single answer to your question. Depends of the tools that you are using, the servers where your app is hosted, etc.
If not, I advise you to use Git to make versions of your app (with Github or Gitlab) and automate the deployment process when you push a new piece of code.
You can make your own scripts to deploy or use online services (surely what you need because of "systems that we press the update button").
I can't advice you one particular service but you would find what you need in Googling "deployment automation github".
I would do it with config files. Considering the code for all my substations is the same. I would have config for each sub-domain and fetch the core files from the same location but serving different data If your structure allows it.
I'm sure this question has been asked before but I can't find one quite the same.
I have an azure cloud service that uses a lot of javascript files. I am still developing the site and so the javascript files change often. When the javascript files have changed I clear my browsing history, selecting 'Temporary Internet files and website files' before re-running the code. However, the website seems to resolutely hold on to my javascript files and keeps running the old code. This is a problem in Chrome, IE and Firefox. If I clear my browsing history a few times it eventually finds the new code.
I know that there are ways to force the browser to reload files by changing the path to the js files for new versions. However I am just testing and don't want to have to update file names each time I change a few lines of code. So I want a way to clear caches within the browser.
I am also using an html5 offline cache for my files so this may be an added complication.
How can I easily clear my old javascript files? Can I do this programmatically?
I have been down this path a few times and no matter what, with no exception, the method that works is adding a query string variable. This is why so many frameworks (e.g., jquery, angular) will add a cache busting date based value to the query string for ajax). Every other method has resulted in one headache or another, browser inconsistencies, random errors because one file updated but the other didn't.
Here's one example I am currently using that is using Angular within ASP.NET:
#{
var v = Request.IsLocal ? DateTime.Now.Ticks : ViewBag.Version;
}
<script>var version = "#v";
<script src="/javascript_file.js?v=#v"></script>
I user a local variable (#v) to set a query string value on the file and I also use it to set up a global JavaScript variable that can be used within js for templates and other files.
If I am working locally, then I always get the latest version of each file. Once I deploy, the version number is set at application start up (using the build version for auto incrementing purposes - so that each deployed version build will have a different version number).
This has the downside that some files that DID NOT change will need to be reloaded, but that's better than trying to tell hundreds of users (hit f5 to reload the page)...
!I am not sure how this will impact offline cache, but I think the same might apply.
I have a QWebView in my app which renders a html page stored in the app as a Qresource. This page, however requires meaty external Javascript libraries such as MathJax, which I would want to include as a resource due to its size.
My problem is that it seems that QtWebkit does not cache these files as a regular browser would do, and every time I refresh the widget it downloads MathJax afresh.
So my question is: is there any way to cache these libraries after first time they are downloaded, without having resorting to shipping it with the app as resource?
You should try if a simple QtNetwork-based download honor the cache setting or not. Also, see if the settings (QWebSettings) are set properly.
In all case, you should be able to inject a custom QNetworkAccessManager that handles the caching of your custom JS library. See http://ariya.blogspot.com/2010/05/qnetworkaccessmanager-tracenet-speed.html and http://ariya.blogspot.com/2010/06/proxy-server-with-filtering-feature.html as examples and follow it up from there.
Could you post some source code? Once downloaded that data will stay in the /tmp/ folder for some time. You could likely use the data in the temp folder, my guess is you are not enforcing that policy.