Bust Browser Cache

Jul 31, 2015 at 5:05 PM
Was looking for a solution to version resources like css and js and found this!

Installed helpful, installed combinator and it never put the time stamps on the link's to the resources.

Using 1.9 from webDeploy in all environments.
Jul 31, 2015 at 10:53 PM
Do you use the latest Combinator source from here?
Aug 3, 2015 at 4:40 PM
no pulled it from the Gallery
Aug 6, 2015 at 6:00 PM
shouldn't the Gallery be the go-to place for the latest modules? I am confused a bit, this module has not been updated in 2 years according to the download page, I would suspect that is plenty of time for the gallery to be updated.

How can i expect my cms users to confidently install the latest modules if a developer has to deploy the latest modules as a code deployable item?
Aug 6, 2015 at 6:23 PM
I didn't have time to spend on continuously creating release packages and uploading them to the Gallery. It gets an issue once you maintain cca. 70 open-source modules and themes like me.
Aug 6, 2015 at 8:37 PM
Edited Aug 6, 2015 at 8:38 PM
Not much use as a CMS if a developer is required to deploy modules honestly. I mean, i must be honest, but it looses a lot of appeal as a CMS if the Gallery is useless.

No offense of course, I understand the load you have, and yet your extremely responsive to alot of people here and elsewhere. Your dedication to Orchard is real!
Aug 11, 2015 at 4:23 PM
Cloned the repositories and all is working now - thanks!
Aug 11, 2015 at 4:37 PM
well, it's not time-stamping js files. :(
Aug 11, 2015 at 5:03 PM
So I guess I am just trying to drive a screw with a sledge hammer.

All i need is to keep browsers from caching items when new ones exist on the server, in the past I've put a query string parameter on the resource and change it when necessary. I thought the bust browser cache feature would do this for me, ( i was directed here from another post )

I may have to solve this one on my own
Aug 11, 2015 at 6:53 PM
Here is my solution, overriding the shapes for the style or script
public class CoreShapeOverrides : IShapeTableProvider
{
    public readonly IVirtualPathProvider _virtualPathProvider;

    public CoreShapeOverrides(IVirtualPathProvider virtualPathProvider)
    {
        _virtualPathProvider = virtualPathProvider;
    }

    public void Discover(ShapeTableBuilder builder)
    {
    }

    [Shape]
    public void Style(dynamic Display, HtmlHelper Html, TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary<string, string> TagAttributes)
    {
        if (_virtualPathProvider.TryFileExists(Url))
        {
            var t = _virtualPathProvider.GetFileLastWriteTimeUtc(Url);
            var u = string.Format("{0}?t={1}", Url, t.ToFileTimeUtc());
            ResourceManager.WriteResource(Html.ViewContext.Writer, Resource, u, Condition, TagAttributes);
            return;
        }

        // do not write to Output directly as Styles are rendered in Zones
        ResourceManager.WriteResource(Html.ViewContext.Writer, Resource, Url, Condition, TagAttributes);
    }

    [Shape]
    public void Script(HtmlHelper Html, TextWriter Output, ResourceDefinition Resource, string Url, string Condition, Dictionary<string, string> TagAttributes)
    {
        if (_virtualPathProvider.TryFileExists(Url))
        {
            var t = _virtualPathProvider.GetFileLastWriteTimeUtc(Url);
            var u = string.Format("{0}?t={1}", Url, t.ToFileTimeUtc());
            ResourceManager.WriteResource(Html.ViewContext.Writer, Resource, u, Condition, TagAttributes);
            return;
        }
        // do not write to Output directly as Styles are rendered in Zones
        ResourceManager.WriteResource(Html.ViewContext.Writer, Resource, Url, Condition, TagAttributes);
    }
}
}
Aug 12, 2015 at 12:53 AM
It's not timestamping resources? That's quite strange... Can't reproduce such an issue.

BTW you may want to add some caching around the VPP operation.
Aug 12, 2015 at 3:00 AM
What i see is it only placing time-stamps on the combined resources. So if everything is combined, it's working fine. Our javascript was not getting combined, i figured that is by design, if not it may have something to do with using coffee-script? we are still deploying js to the orchard site though.

I considered caching time-stamps, but i assumed it was already getting cached by either vpp or some other service that vpp was getting the file info from. :(

thanks for the input!
Aug 12, 2015 at 11:48 AM
Yes, Combinator won't touch (in any way) resources that are excluded, i.e. won't even add timestamps.