• Resolved onetrev

    (@onetrev)


    I’ve setup file name cache busting with .htaccess, but I can’t seem to get it to work in combination with Autoptimize.

    As per HTML5 Boilerplate I am doing this:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp)$ $1.$3 [L]
    </IfModule>

    This routes all requests such as /style.12345.css to /style.css. It works well, but when Autoptimize is enabled, my CSS file shows up blank.

    I am aware the file generated Autoptimize handles the cache busting for you, but it would be really nice to be able to have this recommended file name cache busting working with AO so that you can just leave it in place during development and staging before activating AO. Any chance this is possible or because of how AO works is it just not an option? Thanks!!

    https://wordpress.org/plugins/autoptimize/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Frank Goossens

    (@futtta)

    well, what does it do to Autoptimize-files URL’s?

    Thread Starter onetrev

    (@onetrev)

    Sorry! Key detail I missed.

    The AO files still show up, but as mentioned it CSS file is essentially blank, just has “/*FILESTART*/” in it.

    The AO generated JS file as all my other scripts in it, but the one with the cache busting is missing.

    Probably nothing we can do, but I just wanted to check. No worries if not.

    Thanks so much!

    Plugin Author Frank Goossens

    (@futtta)

    Still not sure I understand.

    Can you give me an example and for that file:
    1. what is the URL without the boilerplate Apache config active?
    2. what is the URL with the boilerplate Apache config active?
    3. what is the filename under which the file is on your filesystem?

    frank

    Thread Starter onetrev

    (@onetrev)

    This might help… see the “File Naming” section (second column) on this site: http://robandlauren.com/2013/04/11/busting-cache-in-wordpress/

    This will route all requests to /path/filename.20130410.css to /path/filename.css.

    In other words, to answer your questions:
    1) /style.123456.css
    2) /style.123466.css … but it points to /style.css as usual
    3) /style.css

    Hope that helps!

    Plugin Author Frank Goossens

    (@futtta)

    OK, now I understand (I’m slow like that 😉 )

    I’ll add a filter to the API that will allow you to act on individual URL’s for CSS & JS-files. Once that is in place you can learn AO that style.123456.css actually is style.css with 3 lines of code and all will be fine.

    I’ll ping you here as soon as you can test this.

    frank

    Thread Starter onetrev

    (@onetrev)

    Awesome sounds good, thanks! Only thing to keep in mind, the name of style.123456.css will continually change since it’s meant to be a cache buster. The file name changes whenever you update your css file. As such I’m not sure if the filter idea will work. No worries if not.

    Plugin Author Frank Goossens

    (@futtta)

    Well, it would be up to the guy or girl using the API filter to decide on what logic to apply, but it would logically contain a preg_replace using a regex that would be similar to what the apache config does;

    ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp)$ $1.$3

    🙂

    Plugin Author Frank Goossens

    (@futtta)

    OK, I just pushed a new version to SVN (& github) which has a filter (“autoptimize_filter_cssjs_alter_url”) you can use to alter the URL before AO tries to aggregate the file. you can download the zip-file from wordpress.org or from github. would be great if you could give that filter a try 🙂

    have fun!
    frank

    Thread Starter onetrev

    (@onetrev)

    Looks good to me! Thank you, awesome support for this plugin as always.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘File name cache busting with Autoptimize’ is closed to new replies.