When going back on my latest app I can only see the code from one of my javascript files that I've included in the assets/javascripts?
If I then try to hit reload it renders the page as I would like it to be.
I just noticed that the same thing occur when I hit forward on my application.
Something with the cache?
Related
I have an e-commerce application that is built on JavaScript and HTML for the front end (uses gulp to bundle). I am facing an issue with it while returning to a page from the back button. On most occasions, the page would simply rerun all the javascript that was initially executed to construct the page. In some rare cases, it behaves as expected which is no JS is executed when the page is hit by pressing the back button on the browser. I confirm that there are no meta headers or response headers that will invalidate the cache. I can see that the rerun is initiated by the browser and not by any of my JS codes. Could someone shed some light on what could cause this to happen?
I'm working with Wamp, and i just added a console.log line.
console.log("message);
However, the message isn't being displayed in the console. After a bit of research, i found out that the source code of the page displayed on my browser ISN'T including the console.log line.
It seems like Wamp isn't recognizing the changes in my code all of a sudden.
I tried restarting it but still the same issue. Any ideas ?
This is javascript you are amending. Javascript is cached in the browser, so if you make a javascript change on the server it is sometimes necessary to tell your browser to refresh all its cache's.
You do this by loading the page you want to see and then pressing CTRL+F5 (both together) The browser will reload the page and all its resources, bringing up your amended javascript from the server in the process.
I have a website in PHP which is completely ajax-based.
There is an index.php, but a part from it, all the other pages are never rendered directly into the browser. Instead, all the post and get requests are done from JavaScript through ajax. So basically, if you go to /contact.php you will not see anything. All the pages are rendered inside index.php.
There are a lot of people that use this page that are not very web-savvy and may not understand what it means when we ask them to refresh the page.
The biggest issue happens when we do a new release. Especially the JavaScript code (but not only) can be the old one in a client's webpage as they maybe haven't refreshed the page for some weeks.
I perform an svn update to publish the new code to the server. Then I refresh my page and see the new features.
However, the people that don't really know how to refresh will not see anything. I have added a big button on the page with the text "refresh", which executes a location.reload.
This may help some people, but not everyone.
How can I "force" the browser to reload itself when a new version has been published?
I would prefer something simple which does not require additional libraries or a timer.
It is also quite important that the page not refresh when the user is doing something with the page, as they may lose work when this happens.
I think you can add a version constant in your code
<?php
define(VERSION, '1.0');
And everytime you call a javascript add this extension
<script type="text/javascript" src="myfile.js?<?php echo VERSION ?>">
So when you'll update version, every js will be recalled by the navigator. Is it more clear?
You can also add a version check web service that will be called before any validate action, so you can refresh page or warn user before doing an action.
Without timer or socket.io you can't refresh page for user.
I am having a problem with my single page application reloading pre-loaded JS files, causing the web application to fail.
I am using AngularJS for a single page application, with a Rails 4 server side, which providers the API, and the template files for the SPA are kept in the rails' public directory.
The problem occurs only when I click the back button, when following links in the application, everything works fine. Say I started on the page /admin/users, if I were to visit /admin/sections, then visit /admin/users again, the /admin/users page will load fine. However clicking the back button twice, and returning to the original /admin/users page, everything is reloaded, the reloading of the JavaScript causes the single page application to crash, as the files are loaded twice.
This has been tried in html5mode set to true and false, the same problem occurs.
Rails is set up to send all /admin/* requests to /admin where angular then works out which template it needs to show by using the url.
(I will provide code samples if required)
I've just upgraded my application to Rails 3.1. I have a fairly complex JavaScript codebase and have opted to concatenate it into a single .js.coffee file to be compiled by Sprockets. Every so often, I'll make changes to one of my CoffeeScript files, refresh the page, and notice my changes weren't reflected. Looking at the Chrome debugger, I notice the files aren't being read from the server (the 'Network' tab shows '(from cache)' on the corresponding files). This seems to happen at random, which makes it very, very frustrating to develop. The only solutions I've found are to clear the browser cache or restart the browser.
Any ideas? I've tried turning :debug on in my javascript_include_tag calls, but was getting the same results. In fact, when I had multiple tags, it seemed that the only assets returning '(from cache)' were those I had changed! That's some irony right there.
Chrome offers an option to disable caching in it's developer tools. Go to Settings, and under Network, there should be a checkbox to disable cache.
I'm unable to replicate. I just created a new Rails 3.1 project, then did
rails generate controller welcome index
deleted index.html, uncommented
root :to => 'welcome#index'
from routes.rb, added the line
console.log 1
to welcome.js.coffee, then fired up Chrome and loaded http://0.0.0.0:3000/. I got 1 on the console. Changed the number to 2, saved, refreshed the page, and got 2. And so on. Doesn't seem to matter whether I hit Cmd+R or just type type in the address; either way I get the latest welcome.js served to me.
Could you "view source" for me? Does your script include look like
<script src="/assets/welcome.js?body=1" type="text/javascript"></script>
or is it different?