Hi I got a strange problem.
When I clicked three pages shown in the following three images
Step 1
controller welcome
Step 2
other controllers
Step 3, go back to the step1 view
controller welcome
The last image,
when I back to controller welcome
from the other controllers
,that is step 2 to step 3.
The stylesheets were cached by the browser,
The step 3's layout is differ to step1 layout.
But they are the same page,How could it be, it seems the browser caches the css files ?
I add two assets folder used by the two layouts, in application.rb
config.assets.paths << "#{Rails.root}/vendor/themes"
themes
├── ace-admin-theme
│ ├── avatars
│ ├── css
│ ├── font
│ ├── images
│ ├── img
│ └── js
└── lenord-single-page-theme
├── css
├── fonts
├── img
├── index.html
├── js
└── rs-assets
Added the welcome.html.haml
under layouts folder, so that welcome_controller
can load this layout
layouts
├── _header.html.haml
├── application.html.haml
└── welcome.html.haml
All the source code I put here https://gist.github.com/poc7667/0198b973fce0fbf4dd26
Page A : OK
Page B : OK
Page A : Failed, the Page B's stylesheets are cached, it should be identical to original page A
It didn't work when I comment the data-turbolinks-track
for the css
The strange phenomenon still occurs.
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -2,7 +2,7 @@
%html
%head
%title VIVOTEK DQA DEVELOPER
- = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
+ = stylesheet_link_tag "application", media: "all"
= javascript_include_tag "application", "data-turbolinks-track" => true
/ Description, Keywords and Author
/ basic styles
diff --git a/app/views/layouts/welcome.html.haml b/app/views/layouts/welcome.html.haml
index 28d9c99..c3e6ec8 100644
--- a/app/views/layouts/welcome.html.haml
+++ b/app/views/layouts/welcome.html.haml
@@ -2,7 +2,7 @@
%html
%head
%title VIVOTEK DQA DEVELOPER
- = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true
+ = stylesheet_link_tag "application", media: "all"
= javascript_include_tag "application", "data-turbolinks-track" => true
I open the firebug to see the included css files,
I found I need to reload the page to load the expected css files.
How to fix it ?
Update
When I reload page, the console showed those css files were loaded
Started GET "/assets/ace-admin-theme/css/bootstrap.min.css" for 127.0.0.1 at 2014-05-19 14:33:49 +0800
Started GET "/assets/ace-admin-theme/css/font-awesome.min.css" for 127.0.0.1 at 2014-05-19 14:33:49 +0800
When I click a hyperlink(by url helper) to other pages the css won't be load again.
But actually it should load the css files again, because some controllers use the different layout and assets.
But what's the worse is that if I click the link (generated by URLhelper) the problems happens
But if I go to the page by typing the URL on the browser manually, it works fine!!
To brief, the css files only load in the first time, and other necessary css files(for other layout) won't be load anymore.(If I view the page by clicking the URLHelperLink), but it works by manually type the URL on the browser (for example: localhost:3000/welcome, localhost:3000/urlcommands)