Caching assets in yii 2 - yii

Is it possible to cache assets, such as js and css, in browser using http control-cache in yii 2? I need to improve my website load time and therefore need to cache my js and css files. I know how to cache a controller action by adding yii\filters\HttpCache to the behavior, but is it possible to do the same for assets?

Javascript and CSS should be already cached from browser. If you investigate with firebug, you will see that .js and .css are taken from the cache.

Related

Serve files from dcos as .html docusaurus

Problem
Noticing when I upload my 'build' content to the server, the md files in docs are breaking.
Not sure why, but there are clearly '.html' files.
But reloading the page doesn't work and i18n doesn't work either.
What confuses me
So, I tried directly accessing the page with '.html' link.
Just to show you,
http://coding-insight.com/docs/python/start/python/ displays 404 when using direct link.
However, using the site's menu bar works.
Reloading results in 404.
But there are clearly html files in the server.
https://user-images.githubusercontent.com/78584173/179334770-46bb6e02-cf6a-4a76-be40-c3fe71038622.png
So, I tried accessing html files directly.
https://coding-insight.com/docs/python/start/python.html
It works. Reloading works.
Question
So, are there any way I could access the html files directly rather than using those '/' at the end?
Is it a bug?

VueJS: Reference static file from public/index.html

I am hardcoding meta og tags into public/index.html as I'm making a single page app. I can't find a way to reference the image from the assets though.
Is it possible to achieve this ? Otherwise I'll just upload it to strapi and have the backend server serve the file.
The next step is to use Nuxt.js to have the website as static files so I'm not really eager to use back-end server to serve the image.

Nuxt plus express caching solution

I have an application that has been created by Nuxt + Express using the kit below:
https://nuxtjs.org/guide/installation
When I check it by https://gtmetrix.com, it shows me that my website does not supporting "Leverage Browser Caching" and listed some URLs such as:
site.com/_nuxt/pages/app.js
site.com/_nuxt/pages/abooutus.js
site.com/_nuxt/pages/contactus.js
site.com/_nuxt/pages/404.js
site.com/_nuxt/images/logo.png
site.com/_nuxt/images/slider1.png
My images and extra CSS files are located in folder static. How can I add this caching layer in this SSR website?

2 dojo base urls

I'm using dojo hosted on google's CDN, which means google's cdn is dojo's base url path. But I have files on my server I want to load with dojo.require. how can I do this? currently I'm getting an error that it can't access the file, but that's because it doesn't exist on google's cdn.
You can config at data-dojo-config or in djConfig
By setting baseUrl and modulePaths
This link would be help. http://dojotoolkit.org/documentation/tutorials/1.6/cdn/

Is a request for the .js files still made if a browser has JavaScript disabled?

When a browser has JavaScript disabled, is the request for the .js files still made to the server (ie the files still end up downloaded on the client, but not parsed) ?
The reason I'm asking is to see if it's worth implementing lazy-loading JavaScript files as to prevent the browser from requesting them if JavaScript is disabled; ie only having a small file that does the lazy-loading which then loads the larger files, so that the large files are not requested if JavaScript is disabled in the browser.
No, it won't.