The invention concerns a method of encoding a data identifier, a network unit of a data network and a computer program product to execute the said method. The data identifier is one of a plurality of data identifiers of a data network. Each of the data identifiers consists of a string of characters. An occurrence probability table is provided which indicates for defined components of the plurality of data identifiers a frequency of occurrence within the plurality of data identifiers. The components are defined based on one or more characteristics of the plurality of data identifiers. Based on the occurrence probability table, the data identifier is encoded according to a variable length encoding algorithm.