If this is your first visit, check our documentation. To post, register or login.
Forums / Community Contributed Add-Ons / All Other Contributions/Addons / File Auto-Versioning (CSS, JS, etc) for Templates [Support Thread]

File Auto-Versioning (CSS, JS, etc) for Templates [Support Thread]

Started by lat9 on 4 Jan 2017, 2:25 PM · Views: 3,042

Results 1 to 12 of 12
4 Jan 2017, 2:25 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #1 by lat9

Starting with Zen Cart® 1.5.2, additional rules have been added to your store's /includes/.htaccess instructing the customer's browser to cache images, PDFs, CSS and javascript files for certain periods. While that caching provides your site with a performance "boost", it's not without cost … what happens if you've added a plugin that adds some styling to your current template's stylesheet.css? The short answer is that until the customer specifically refreshes their browser or clears their browser's cache (possibly multiple times), those changes won't be pulled from your site because the browser has been told to *cache *that file's contents!

That's where File Auto-Versioning comes into play. You can use this plugin to add a version string to those file "assets" so that your customers' browsers are always pulling in the most recent content.

I'll be submitting this to the Plugins in a bit and will update this support-thread once I've got a download link.

4 Jan 2017, 4:06 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #3 by drbyte

Would it be safe to say this should be called "Asset Auto-Versioning" instead of merely "File Auto-Versioning"?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Jan 2017, 4:16 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #4 by lat9

DrByte:

Would it be safe to say this should be called "Asset Auto-Versioning" instead of merely "File Auto-Versioning"?
Kind of, sort of ... I guess. The point is that the auto-version is the return value from the PHP ***filemtime ***function, so whether its a *file *or an *asset * there's a file involved.

4 Jan 2017, 9:47 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #5 by drbyte

Agreed. I was looking at it from the perspective of someone looking at a list of plugins and trying to understand what they do by their name, and deciding whether they might need to install it on their shop. It felt like "file versioning" might imply "managing versions of every file in my Zen Cart", thus maybe more of an upgrader-tool.

This is more of a "cache-buster" by adding a version stamp to the URL.

Just passing along my observation.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Jan 2017, 11:52 PM
#6
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,572
Plugin Contributions:
60

Post #6 by numinix

DrByte:

Agreed. I was looking at it from the perspective of someone looking at a list of plugins and trying to understand what they do by their name, and deciding whether they might need to install it on their shop. It felt like "file versioning" might imply "managing versions of every file in my Zen Cart", thus maybe more of an upgrader-tool.

This is more of a "cache-buster" by adding a version stamp to the URL.

Just passing along my observation.
I agree with Dr Bytes assumption. When I saw this thread I thought it updates the version number in PHP files. I'd go a little beyond and say Browser Asset Auto Versioning.

5 Jan 2017, 6:43 AM
#7
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Post #7 by website_rob

Module not yet available so I cannot find out details but here is my question.

stylesheet.1194900443.css <- is this similar to what the filename will look like using the module?

If yes, perhaps "Filename Revisioning" would be more applicable as a Module name?

The learning is in the doing.

Potent Products

5 Jan 2017, 12:37 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #8 by lat9

The plugin (see its GitHub repository for the current readme) doesn't actually modify any files, it simply generates an HTML attribute containing the file's last-modified time (e.g. stylesheet.css&293729837) to "trick" the browser into grabbing the updated file's contents.

5 Jan 2017, 12:39 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #9 by lat9

DrByte:

Agreed. I was looking at it from the perspective of someone looking at a list of plugins and trying to understand what they do by their name, and deciding whether they might need to install it on their shop. It felt like "file versioning" might imply "managing versions of every file in my Zen Cart", thus maybe more of an upgrader-tool.

This is more of a "cache-buster" by adding a version stamp to the URL.

Just passing along my observation.

numinix:

I agree with Dr Bytes assumption. When I saw this thread I thought it updates the version number in PHP files. I'd go a little beyond and say Browser Asset Auto Versioning.
Thanks, guys, I'll go with @numinix's "a little beyond" as it fully describes the plugin's function. I'll get that name changed for the next go-round.

19 Jul 2017, 3:57 PM
#11
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,906
Plugin Contributions:
23

Post #11 by dbltoe

Placed an item on github but wanted to let non-gitters (sp) know.

In the includes/templates folder there are two folders -- YOUR_RESPONSIVE_TEMPLATE and YOUR_TEMPLATE.

Would it be better to name the YOUR_TEMPLATE to template_default since the header_html.php file is not meant to be used in a responsive environment?

One customer overwrote the file in responsive_classic despite the instructions mentioning that the file is the template_default version modified specifically for this mod.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

19 Jul 2017, 7:26 PM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,144
Plugin Contributions:
56

Post #12 by lat9

dbltoe:

Placed an item on github but wanted to let non-gitters (sp) know.

In the includes/templates folder there are two folders -- YOUR_RESPONSIVE_TEMPLATE and YOUR_TEMPLATE.

Would it be better to name the YOUR_TEMPLATE to template_default since the header_html.php file is not meant to be used in a responsive environment?

One customer overwrote the file in responsive_classic despite the instructions mentioning that the file is the template_default version modified specifically for this mod.
Placing the /common/html_header.php changes in template_default would make it less "obvious" that the change needs to be made to the version used for (er) your template. I've yet to come across a template that doesn't have some kind of modifications to that file.

I'll review the installation instructions to attempt to make it more obvious what needs to be changed and where!