Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache buster config option #42

Merged
merged 2 commits into from
May 17, 2018
Merged

Add cache buster config option #42

merged 2 commits into from
May 17, 2018

Conversation

mrtbld
Copy link
Contributor

@mrtbld mrtbld commented Jun 7, 2016

This allows users to give a version tag or timestamp that is automatically included in the font files URLs as a query string parameter. This is useful to bust HTTP caches when deploying new versions of icon fonts.

This is different approach than @lzl124631x's P/R #39. It doesn't force any tagging scheme (timestamp, version number, whatever) since it is provided by the user. It works out of the box: no need to use a custom CSS template, just set cacheBuster to something (of course you can use it in custom templates too).

The default behavior is the same as before.

Review appreciated. :-)

@mkhazov
Copy link

mkhazov commented Jul 30, 2016

Looks good!
I think README.md should be updated as well.

@lmartins
Copy link

lmartins commented Nov 5, 2016

Any chance of this being merged?

@jefsnare
Copy link
Collaborator

jefsnare commented Mar 3, 2017

@backflip Please contact me, I want to help with reviewing the PR's if you want to

@backflip
Copy link
Owner

backflip commented Mar 3, 2017

Hey @jefsnare, sounds awesome! I have added you as a collaborator.

@jefsnare
Copy link
Collaborator

jefsnare commented Mar 3, 2017

@backflip Cool, only write access should be nice, I can't merge or add changes. Can you provide this permission?

@backflip
Copy link
Owner

backflip commented Mar 3, 2017

Not sure, but you'll probably have to accept the invite first. I might be able to fine-tune permissions afterwards:

image

@jefsnare
Copy link
Collaborator

jefsnare commented Mar 3, 2017

@backflip Done, missed that email for some reason. Thank you!

@backflip
Copy link
Owner

backflip commented Mar 3, 2017

I can add you as an npm owner, too, if you provide me with your username. This would allow you to publish releases.

@jefsnare
Copy link
Collaborator

jefsnare commented Mar 5, 2017

@backflip my username is jefsnare on NPM

url('<%= fontPath %><%= fontName %>.ttf') format('truetype'),
url('<%= fontPath %><%= fontName %>.svg#<%= fontName %>') format('svg');
src: url('<%= fontPath %><%= fontName %>.eot<%= cacheBusterQueryString %>');
src: url('<%= fontPath %><%= fontName %>.eot?<%= cacheBuster %>#iefix') format('eot'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using assigned var cacheBuster instead of also using cacheBusterQueryString ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because for EOT format, the IE fix needs to always have the ? of the querystring whether or not a cache buster is used. When it is not, for other formats the ? is ommitted but not for EOT.

This is the only difference between the two vaiables cacheBusterQueryString and cacheBuster: the former include the ?, the latter doesn't. I used to variables for this because having ifs in the template made the whole thing less readable (too much clutter).

(Sorry for the late response!)

@jefsnare jefsnare added this to the Release 2.2.0 milestone Mar 5, 2017
mrtbld added 2 commits April 4, 2017 14:31
This allows users to give a version tag or timestamp that is
automatically included in the font files URLs as a query string
parameter. This is useful to bust HTTP caches when deploying
new versions of icon fonts.
@mrtbld
Copy link
Contributor Author

mrtbld commented Apr 4, 2017

I just rebased this PR on master, and added a fixup to add documentation (and simplify code a little bit). Left the fixup so that you can see the changes but it should be squashed before merge.

However tests don't pass anymore on my computer; don't know why. The test this PR adds is still OK but the ones that was there before are not OK anymore for some reason. It seems to be a difference in generated font vs expected. I'm guessing a dependency changed the way it generates font files a bit.

Are you able to reproduce this issue?

Test output:

1) gulp-iconfont-css should generate SCSS file and fonts:

      Uncaught AssertionError: 'wOF2\u0000\u0001\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u000b\u0000\u0000\u0000\u0000\u0006�\u0000\u0000\u0002�\u0000\u0001\ == 'wOF2\u0000\u0001\u0000\u0000\u0000\u0000\u0002�\u0000\u000b\u0000\u0000\u0000\u0000\u0006�\u0000\u0000\u0002�\u0000\u0001\u0000
      + expected - actual

      -wOF2��
             ������B�V�~
      -�h�W�6�$�

               � �r:������d_aS�|���̌�R���]��~`�R����<��}�����˄
      -i<P	Ș�J`�U�t��A��U�{��h�����y��@�TE��u�k �f��	���\�
                                                                     {�mG7�|�<�L7N�O_���j��{�M��:;O���OW�����؀;����4��l�i�}��Ȋ=d��X�h�!@�$����~l�l� 8;�ݸ
                                                                                                                                                       ��6a9��\
ST;��8G��@�y�� �0 ��v���u*5��X������#� �����+���9��ȡa��0����jO                                                                                                 U��e��7�&�4f���3
                                                              ��l���������e�դN<|������a�����t��GҖ�K9[�6�'�TxN�%����a��s�Ŀ�����?N�ߗ����u�*W��ַ�>�PoB��^�X��U=��c��"��M����7k�1ezQ����a
    �����*����+F���v�s�����S�a?���	���i��$�}N�蒒�5�(��<��a��A�uc�d2�C����K 9�b�%����g_&5	e�H���R��C���4������
                                                                                                                    ��wI
                                                                                                                        �q)S�o�[�.��T!e`jF���3�6����[�b� $����1rI�����Rׅ�Sͥ��s)S�o�[�T���T�2��4F��Y�m3z�:@���f��uS
      -�9.8�$�rY�.k�D�/�{�����f:�fF���-2�����8u�
                                                �Q�
      -
      +wOF2���
              ������B�V�~
      +�h�Y�6�$�

               � �r:���.�mؓ��
      +$`9��
            �Do�6ou�n��P��*�m������_]M����e��FM���H����w���SU���-/Iu����^#<������-���	`s�᧛�1���
                                                                                                 x�����e�����|��!�=��=�葏	���Q�;��
                                                                                                                                        ���* �ޡ]h�|��Ke���lK)7�������j��"iL���z��Y)�"ͨԀ�S��$�Ufn���xE�������(E��S
      +�	���ᯫ��`����p����6H
                                  �^��XN܆��Ce���k=�v��Î
                                                       ��n�o;���OKK��������M�{5?���p���M�Y�kq��˔��
      +G[s��GS���:�a�����ߧo�g�����P�e�����6��>��{�wg��}ߪ�����j@�|h��0kb�4��f\7%��w~-G������;�2����u�G_)4Ë��i��9	�}�d��׊" f,pc@lhpe�\��2���A�n$�Iz�q�+%X-P��=+v������ I� ���H��d,w�J��d��%��= s������l�&���q����y?dl�9nj�^qK9�W(@o�v�G"
      +��
         o8�JS��pL��B���?v��Ӟ��������hc)�������V������5�1�%Hp�gY�ڈ�
      +RT�2�&&8{S)�
      +{^��DO�����4�5{����[�En�C���ȶ��p�5�X$B�
      
      at test/main.js:51:12
      at Stream.<anonymous> (node_modules/event-stream/index.js:318:20)
      at _end (node_modules/through/index.js:65:9)
      at Stream.stream.end (node_modules/through/index.js:74:5)
      at DestroyableTransform.onend (internal/streams/legacy.js:44:10)
      at node_modules/vinyl-fs/node_modules/readable-stream/lib/_stream_readable.js:965:16
      at _combinedTickCallback (internal/process/next_tick.js:73:7)
      at process._tickCallback (internal/process/next_tick.js:104:9)

@backflip
Copy link
Owner

@mrtbld, I have updated the test files in master, I guess the woff packages were updated upstream.
Thanks a bunch for this new feature!

@backflip backflip merged commit 3330d4b into backflip:master May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants