How can I force client to not cache the svelte/rollup bundle.js? - browser-cache

My svelte rollup.js setup has an index.html file with this head:
<link rel='stylesheet' href='/build/bundle.css'><!-- svelte -->
<link rel="stylesheet" href="/build/index.css" /><!-- tailwind -->
<script defer src='/build/bundle.js'></script>
When I deploy a new version to my web server, some clients don't fetch the new bundle.js but instead use their cached copy. What's a good way of forcing them to fetch the new bundle when I've deployed a new version?
The simplest way I can think of would be to add the version number or git commit hash to the end of src, e.g:
<link rel='stylesheet' href='/build/bundle.css?v0.1.4'><!-- svelte -->
<link rel="stylesheet" href="/build/index.css?v0.1.4" /><!-- tailwind -->
<script defer src='/build/bundle.js?v0.1.4'></script>
But I assume this is a common problem, so I'd rather ask.

There's a section in the docs about using hash's in the bundle names. https://rollupjs.org/guide/en/#outputentryfilenames

Related

What does ERR_CONTENT_DECODING_FAILED

This is the error code I am getting. I am a novice at this and could really use some help. I happened to open the "developer" tool in Chrome and might have made a mistake or something because now I cannot see my slider or testimonials. Can anyone help? Sorry if my question is not posed correctly, I am having a panic attack and this is my first time using this form. The slider works fine in other browsers, just not Chrome -- all of a sudden.
GET https://fitkidsstage.com/wp-content/plugins/revslider/public/assets/css/settings.css?ver=5.1.6 net::ERR_CONTENT_DECODING_FAILED
jquery-migrate.min.js?ver=1.4.1:2 JQMIGRATE: Migrate is installed, version 1.4.1
(index):1078 GET https://fitkidsstage.com/wp-content/themes/kindergarten/js/main.js?ver=4.9.5 net::ERR_CONTENT_DECODING_FAILED
(index):1080 Uncaught SyntaxError: Unexpected token .
From here:
It happens when your HTTP request's headers claim that the content is gzip encoded, but it isn't. Turn off gzip encoding setting or make sure the content is in fact encoded.
This loads fine in Chrome (Version 65.0.3325.181 (Official Build) (64-bit)) though (exception running the script due to other missing dependencies), so your problem may be elsewhere.
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E="
crossorigin="anonymous"></script>
<link rel="stylesheet" href=" https://fitkidsstage.com/wp-content/plugins/revslider/public/assets/css/settings.css?ver=5.1.6">
<script src="https://fitkidsstage.com/wp-content/themes/kindergarten/js/main.js?ver=4.9.5 "></script>
<body>
<div>
Hi
</div>
</body>

Odoo 10 js cache

I everyone, i have a problem developing a custom module on odoo 10.
When i modify a js or a css, imported into the view.xml in this way
<template id="makeit.assets_common" name="makeit assets common" inherit_id="web.assets_common">
<xpath expr="." position="inside">
<!-- All links to CSS and JS files should be added in here. -->
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css"/>
<link href="/makeit/static/src/css/jquery.tagit.css" rel="stylesheet" type="text/css"/>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.171.0.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script>
<script src="//cdn.jsdelivr.net/bluebird/3.5.0/bluebird.min.js"></script>
<t t-call-assets="web.assets_backend" t-css="false"/>
<link rel="stylesheet" href="/makeit/static/src/css/makeit.css"/>
<script type="text/javascript" src="/makeit/static/src/js/custom_js_v93.js"></script>
</xpath>
</template>
as you can see i have to change the name of the custom_js_v93 every time to make it work.
I've tried reloading db, odoo service, module ecc.
any idea? thank you
If your changes are in *.py files, restart the odoo service.
service odoo restart
If your changes are in existing *.xml files, re-install (upgrade) the module.
Apps > Your module > Upgrade
If your changes are in both, the do the both: restart the service then upgrade the module.
I don't think clearing browser cache is necessary, since Odoo automatically generates new *.js files (and removes the old ones) every service start:
http://odoo.example.com/web/content/6045-b6fe286/web.assets_backend.js
^
This is generated
So in your case, just reinstall the module.
Updated:
Try changing to inheritance of inherit_id="web.assets_backend" if it fixes your issue:
<template id="makeit.assets_common" name="makeit assets common" inherit_id="web.assets_common">
to
<template id="makeit.assets_backend" name="makeit assets backend" inherit_id="web.assets_backend">

Laravel is searching for CSS file in wrong directory when using Elixir

Why is Laravel searching for my CSS file in the wrong directory? I've seen this question posted a few times but it's never actually been answered with Elixir. I am assuming there are possibly some configurations that need to be done which aren't covered in the documentation (at least from what I can tell).
My layout.blade.php file links to the css stylesheet as follows:
<link rel="stylesheet" href="{{ elixir('css/app.css') }}">
My CSS file is loaded in the following path:
localhost/fresh/public/build/css/app-279b78681b.css
However,it is looking for the file here (it is notably missing /Fresh/public/ which I can't determine why?):
localhost/build/css/app-279b78681b.css
I am running an Apache 2.4 webserver for my laravel 5.2 project (not on homestead and not on a VM) and my gulpfile.js file has the following code:
elixir(function(mix) {
mix.sass('app.scss')
.version('/css/app.css');
});
All of that being said, if I were to change my layout.blade.php file to the following:
<link rel="stylesheet" href='css/app.css'>
It will capture my stylesheet that is located in the following directory correctly:
localhost/fresh/public/css/app.css
Sooooo, why can't it capture the css stylesheet when i use Elixir and why is it linking the wrong location?
I have the same problem too.
I used as workaround:
<link rel="stylesheet" href="{{ url(elixir('css/app.css') }}">
or
<link rel="stylesheet" href="{{ asset(elixir('css/app.css')) }}">
It's just that it outputs absolute path then in the generated file. It works but I don't like it so am also still interested how to fix it properly.

IBM Worklight with Dojo Toolkit | dojo/main.js 404 not found issue

I have recently started exploring IBM Worklight which looks really promising to build hybrid mobile apps, in order to do so, created a Worklight project while choosing Dojo Toolkit as a default framework choice and got to see the missing dojo/main.js issue.
Here is the HTML code:
<!DOCTYPE HTML>
<html>
<head>
<title>TD_Mobile</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="dojo/dojo.js" data-dojo-config="isDebug: false, parseOnLoad: true, async: false"></script>
<link rel="stylesheet" href="css/TD_Mobile.css">
</head>
<body id="content" style="display: none;">
<div data-dojo-type="dojox.mobile.ScrollableView" id="view0"
data-dojo-props="selected:true"></div>
TD_Mobile
<!--application UI goes here-->
<script src="js/initOptions.js"></script>
<script src="js/TD_Mobile.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
When I do build and deploy and run the project from worklight console as a common resource, got to see the main.js not found issue at the following path http://localhost:8080/apps/services/preview/TD_Mobile/common/1.0/default/dojo/main.js
And to my surprise further, I was able to search the reference folder at C:\Users\marif\workspace\WorklightServerHome\TD Mobile New\widget-resources\TD_Mobile-common-e6cd3d9088c88e96df743ed1c9a1b584a90da8c9\preview\default\dojo and don't see main.js and some more JS files there.
Looks like final deployed build somehow not working properly, would appreciate for any quick pointer.
Not all files are included in the dojo build, there is a file called build-dojo.xml in your project.
Add main.js to it.
Under <patternset id="dojo.resources.loose-modules"> add the modules you want to use.
This sounds like a write permissions issue.
Can you please create a new project and see if it happens there as well?
If it does not then the issue is solved, else it might be a plugin issue.
Do you get any error message is the Worklight console in the build process?

Loading Dojo dijit CSS from CDN

I am quite new to dojo world.
Using dojo with google's CDN is well and Fine. But while using dijit just dojo.require() does not work. Where can I find the default CSS Themes from CDN ??
and another question out of quorisity:
Would the the CSS configuration for dijit work for dojox too ??
The CSS can be found on Google's CDN. I've used it in a page or two. Here's some CSS link tags.
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/resources/dojo.css">
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css">
Much like the libraries, you can pick a more or less specific version in the URL, so this will grab the latest in the 1.4.x chain.
UPDATED [19/May/2016]:-
Update version - 1.10.4
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css">
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/tundra/tundra.css">
Here is 1.9.1.
Theme Tester: Claro, Tundra, Nihilo, and Soria
Claro - http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/claro/claro.css
Tundra - http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/tundra/tundra.css
Nihilo - http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/nihilo/nihilo.css
Soria - http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/soria/soria.css
Here is 1.10.4.
Theme Tester: Claro, Tundra, Nihilo, Soria
Claro https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css
Tundra https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/tundra/tundra.css
Nihilo https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/nihilo/nihilo.css
Soria https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/soria/soria.css
Well, As we know 1.11.2 version also has been released so below are the cdn links for that-
Claro: https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dijit/themes/claro/claro.css
Tundra: https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dijit/themes/tundra/tundra.css
Nihilo: https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dijit/themes/nihilo/nihilo.css
Soria: https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dijit/themes/soria/soria.css
Hoping this will help you :)