According to the Carto.js documentation, layer.invalidate():
"Refreshes the data. If the data has been changed in the CARTO server those changes will be displayed. Nothing happens otherwise. Every time a parameter is changed in a sublayer, the layer is refreshed automatically, so there’s no need to call this method manually."
However, I'm wondering if I'm not using invalidate properly. I have changed data in the CARTO server (ie. table values), however calling layer.invalidate() doesn't refresh my map.
cartodb.createLayer(map, {
user_name: 'user_name',
type: 'cartodb',
sublayers: [
//Baselayer
{
type: "http",
urlTemplate: 'http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png',
subdomains: [ "a", "b", "c" ]
},
//Projects
{
sql: "SELECT * FROM ab",
cartocss: '#ab {marker-fill: #15B14D;}',
interactivity: ['name', 'description', 'source', 'contact', 'category'],
},
//Labels
{
type: "http",
urlTemplate: 'http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png',
subdomains: [ "a", "b", "c" ]
},
],
})
.addTo(map)
.done(function (layer){
cartodb.vis.Vis.addInfowindow(map, layer, ['name', 'description', 'source', 'contact', 'category'],{
infowindowTemplate: $('#infowindow_template').html(),
templateType: 'mustache'});
layer.invalidate();
});