Laravel app serving resources that do not exist? - css

I am in the process of adding a Content Security Policy for a laravel application. While downloading external css and font styles to the local assets I have run into some odd template behavior.
I wanted to test that the paths to the newly downloaded libraries were correct, but when I change the name of files I downloaded and refresh, even with the browser cache disabled, it is still referencing the old location successfully. If you try to access the file in the old location directly by file path it fails (because it no longer exists).
Even more strangely, if I pull the code down to another computer and run it (I have not added the new libraries to git yet), the page still seems to think it correctly loaded that resource.
I tried clearing the following directories:
storage/framework/cache
storage/framework/sessions
storage/framework/views
and running the code again - on multiple computers, and it still reports that it is loading these files that are no longer there?
Does Laravel or commonly used front end frameworks with it store compiled templates somewhere else? I am completely perplexed...

Related

Why doesn't Uvicorn pick up Changes to CSS files?

I'm using FastAPI and the Uvicorn server to build a website, but when I make changes to the CSS files and reload the webpage it doesn't pick up these changes.
In fact, even when I switch off the server and reload it, Uvicorn still doesn't pick up the changes to the CSS file.
Previously, the server picked up the changes fine, what's caused this to change?
The issue is not with Uvicorn, but with your web browser stashing 'static' files in its cache.
FastAPI uses a method that designates a directory the 'static folder'. This tells the server that the files in this directory should remain constant and don't need to be downloaded every time a webpage is loaded.
Check inside your app's main module and look for the following piece of code:
app.mount(
"/your_static_file_web_path",
StaticFiles(directory="your_static_directory"),
name="your_name_for_static_app"
)
This function creates a second FastAPI app within your pre-existing one that handles all of your static files. The second argument defines your static file directory. Anything within that directory will eventually be cached by your web browser and further changes will not be loaded. This prevents your page from loading the updated CSS.
As noted in a comment above, if you want to work around this issue, you can hold shift and reload the web page - this is known as a hard refresh. A hard refresh will force your browser to re-download everything, including static files.

Custom Domain not loading CSS (Azure)

The custom domain I've been using (which is already linked to an App Service in Microsoft Azure Portal) is not loading the my current styles files (.css files). Actually, it's loading older versions of those files, which I didn't create (they've had been created previously by another employee).
Has someone experienced this same issue? If I go to the website created by the App Service, the .CSS loaded there is correct (the one I've created), but whenever I go to the custom domain linked with this website, the .CSS loaded is older.
Clearing the browser cache will work locally. However, other repeat visitors will have the same issue you are having. A global method would be to rename your CSS file. That will force the browser for repeat visitor's to load the new/ current CSS file.
ex. "style.css" --> "styles.css"
Rename the CSS file and don't forget to rename the meta link as well.
Try clearing browser cache memory. CSS files are often get cached in the browsers.

Forcing Cache refresh after deploying new code

We are running into issue where our clients are served stale js, css files after code is deployed. We are using IIS as our webserver and our code is in ASP.Net 4.5. I did some research and figured out that ETag in conjunction with Cache-control should work. As I understand ETag is automatically generated by web server based on datetime stamp of file so I ran following steps to see why the system is not sending the latest version of js and css files.
Navigated to my website to a webpage let's call is demo.aspx.(Now assuming that demo.aspx contains reference to a.js, b.js and c.css)
Verified that a.js, b.js and c.css file were requested by browser and webserver delivered those files after I hard refersh a page(Ctrl + F5) on my website.
Clicked on some other webpage
Went to webserve and manually updated files (a.js, b.js and c.css to update datetime stamp of those files)
Navigated to demo.aspx again.
This time I see only request made to demo.aspx but not to any of the resource file (a.js, b.js and c.css).
I am at loss as to why .js files are not requested when I access my demo.aspx page.
Also, Is there any easy way to force client browsers to download latest version of .js and .css files every time I deploy code. Based on my research, I did find out that one way to do would be to rename .js and .css file. Please note that this soution won't work for us.
We do use update panel in our projects. Not sure if that has anything to do with browser not requesting js files second time
A widely used trick is to add a query string parameter that is incremented with every new version of the css or js file.
Like myScript.js?version=12. When the the number changes the browser sees it as a new file and it's downloaded rather than retrieved from cache.
Just changing the timestamp by editing the file won't work, the browser does not get the timestamp from the server. You can try this by saving an image or file from the website, they all have the timestamp of when they were being downloaded.

Problem in flex project

I am using Adobe Flash Builder 4 trial version.
I created one abc.mxml application which is working fine in the IDE. Now, I want to use the generated abc.swf in one of my application so I copied
abc.swf
abc.html
and related .js and .css files
to some other location in the file system. After that when I tried to launch the abc.html in the browser, nothing was appearing in the browser.
After that I copied the whole flex project at some other location and tried to launch the same abc.html file. Even that was also not working.
I don't know what's the problem.
Edited ============================================================================
My money is on sandbox security issue. Either keep the files under bin-debug to prevent it or add your folder and flash file to be allowed in the Flash Security Settings.
This is cross-site scripting situation, read this: http://kb2.adobe.com/cps/142/tn_14213.html.
You launch abc.html (which consist adc.swf) from one domain ("file:///c: ..."), but refers for data from another (is there you red5 installed, probably localhost).
Create cossdomain.xml in the root directory in ther server (red5).

Loading a video from the local file system

I have a swf that is run from C:/ in the browser instead of a server (long story) and that swf loads a video that it located at ../../videos/video in relation to that swf.
Problem is, When I run it in Flex, everything is cool. Running locally, it can't find the file (not a security error) and is throwing a connectionError.
Any ideas?
NOTE: This seems to be a Windows specific problem, it's running on my mac with the same security settings just fine.
Flex Builder has a file that it adds all of your bin directories to in order to allow the debug player to get around the local security restrictions.
Here's a blog post on the subject.
Essentially Flexbuilder tells Flash that it should trust the bin folder... if you do a search on your development machine for the file flexbuilder_plugin.cfg, you should find it in a folder called FlashPlayerTrust in roughly the same area you normally find SharedObject files. If you open this file in a text editor, you should see pretty much every path to every bin folder for every flex project you have ever worked on. And suddenly everything gets so much clearer.
You can do as fenomas suggests and add any directory to your trusted list. You can also follow the advice from the above blog post.
So I created a new file and placed it next to this flexbuilder_plugin.cfg file, and called it MyProggy.cfg. Flash is configured to read in all files in this folder and parse all paths out of it, and any applications run from these paths will be considered "localTrusted" and will act as they would when run from Flexbuilder. Inside this text file I put one line: "c:\program files\my proggy" and saved it. I then had to restart Firefox for the change to take effect. I also had added a text label to my application and bound the text property to {Security.sandboxType}.
I would suggest getting HTTPFOX for Firefox which is a sniffer. Then you can see what is failing. In my own search I found that FLV's are always relative to the SWF, even when loaded on the WEB. Every asset that I have loaded is relative to the index.html file except for FLV's which always remain relative to the SWF. Being able to watch the data flowing, or attempting to flow to your site is invaluable.
This also explains why some people have no issue loading thing locally but then run into problems on the web. If their html file that is loading the swf is in a different location than the swf then every asset other than FLV's have a different relative path when viewed online then they do when viewed locally.

Resources